www.pudn.com > MFCtest.rar > PDH.h
// PDH.h: interface for the CPDH class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_PDH_H__E7AE97EE_6C61_4806_9F64_A7642F4A8F4A__INCLUDED_) #define AFX_PDH_H__E7AE97EE_6C61_4806_9F64_A7642F4A8F4A__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define LEN sizeof(struct ProcessInfo) #define PRONAME info[0] #define PID info[1] #define PPID info[2] #define TIME info[3] #define THREADCOUNT info[4] #define USERTIME info[5] #define HANDLECOUNT info[6] #define PRIORBASE info[7] #define WORKSET info[8] #include#include #include #include #include #pragma comment(lib,"pdh.lib") #pragma comment(lib,"mpr.lib") struct ProcessInfo { DWORD instanceIndex; TCHAR info[10][16]; ProcessInfo *next; }; class CPDH { private: LPTSTR szMachineName,password,accont; ProcessInfo *head,*p1,*p2; LPTSTR szCounterListBuffer; DWORD dwCounterListSize; LPTSTR szInstanceListBuffer; DWORD dwInstanceListSize; HQUERY hQuery; HCOUNTER hCounter; TCHAR szPathBuffer[MAX_PATH]; DWORD ctrType; PDH_FMT_COUNTERVALUE fmtValue; PDH_STATUS pdhStatus; ProcessInfo *pi,current_pi; TCHAR counterName[9][32]; ProcessInfo *addnew(); bool setInstanceIndex(ProcessInfo *pi); bool ConnIpc(); bool destroyProcessInfo(); public: int num; CPDH(LPTSTR szMachineName,LPTSTR accont,LPTSTR password); CPDH(); virtual ~CPDH(); int processNum(); ProcessInfo *currentProcess(); bool goNextProcess(); bool goFirstProcess(); bool hasNext(); bool getProcessInfo(); }; LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; HWND CreateListView (HWND hwnd,CPDH *pro); bool display(HWND hListView,CPDH *pro); #endif // !defined(AFX_PDH_H__E7AE97EE_6C61_4806_9F64_A7642F4A8F4A__INCLUDED_)