CpuUsage.h
上传用户:hkcoast
上传日期:2007-01-12
资源大小:979k
文件大小:1k
源码类别:

手机短信编程

开发平台:

Visual C++

  1. // CpuUsage.h: interface for the CCpuUsage class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_CPUUSAGE_H__60CF4F03_9F01_41E8_A9FB_51F065D5F3C2__INCLUDED_)
  5. #define AFX_CPUUSAGE_H__60CF4F03_9F01_41E8_A9FB_51F065D5F3C2__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #pragma warning(disable : 4786) //debug info - name too long
  9. #endif // _MSC_VER > 1000
  10. #include <pdh.h>
  11. #include <pdhmsg.h>
  12. #pragma comment(lib,"PDH.lib")
  13. #define MAX_RAW_VALUES          20
  14. const char szCounterName[] = "\Processor(_Total)\% Processor Time";
  15. typedef struct _tag_PDHCounterStruct {
  16.     HCOUNTER hCounter;      // Handle to the counter - given to use by PDH Library
  17.     int nNextIndex;         // element to get the next raw value
  18.     int nOldestIndex;       // element containing the oldes raw value
  19.     int nRawCount;          // number of elements containing raw values
  20.     PDH_RAW_COUNTER a_RawValue[MAX_RAW_VALUES]; // Ring buffer to contain raw values
  21. } PDHCOUNTERSTRUCT, *PPDHCOUNTERSTRUCT;
  22. class CCpuUsage  
  23. {
  24. public:
  25. CCpuUsage();
  26. virtual ~CCpuUsage();
  27. BOOL Init();
  28. int GetUsage();
  29. protected:
  30. PPDHCOUNTERSTRUCT m_pCounterStruct;
  31. HQUERY m_hQuery;
  32. };
  33. #endif // !defined(AFX_CPUUSAGE_H__60CF4F03_9F01_41E8_A9FB_51F065D5F3C2__INCLUDED_)