50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
// GetProcessInfo.h: interface for the CGetProcessInfo class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#if !defined(AFX_GETPROCESSINFO_H__7FA81773_F785_4A4D_8A97_1FA04FD3B458__INCLUDED_)
|
|
#define AFX_GETPROCESSINFO_H__7FA81773_F785_4A4D_8A97_1FA04FD3B458__INCLUDED_
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif // _MSC_VER > 1000
|
|
|
|
typedef struct
|
|
{
|
|
DWORD ExitStatus;
|
|
DWORD PebBaseAddress;
|
|
DWORD AffinityMask;
|
|
DWORD BasePriority;
|
|
ULONG UniqueProcessId;
|
|
ULONG InheritedFromUniqueProcessId;
|
|
}PROCESS_BASIC_INFORMATION;
|
|
|
|
typedef LONG (WINAPI *PROCNTQSIP)(HANDLE,UINT,PVOID,ULONG,PULONG);
|
|
|
|
class CGetProcessInfo
|
|
{
|
|
public:
|
|
CGetProcessInfo();
|
|
virtual ~CGetProcessInfo();
|
|
|
|
//通过进程名称获取进程ID,同时也可通过传个引用参数获取到父进程ID,同下面GetParentProcessId获取的结果一致
|
|
DWORD GetProcessIdFromName(CString strProcessName, DWORD &dwParentProcessId);
|
|
|
|
//通过子进程ID获取其父进程ID
|
|
DWORD GetParentProcessId(DWORD dwChildProcessId);
|
|
|
|
//通过进程ID获取进程名称
|
|
CString GetProcessNameFromId(DWORD dwProcessId);
|
|
|
|
//通过进程名来获取指定的子进程(通过指定父进程进行约束)
|
|
DWORD GetSpcialProcessIdFromName(CString strProcessName, DWORD dwParentProcessId);
|
|
|
|
static CGetProcessInfo* CreateInstance();
|
|
|
|
protected:
|
|
static CGetProcessInfo* m_pGetProcessInfo;
|
|
|
|
};
|
|
|
|
#endif // !defined(AFX_GETPROCESSINFO_H__7FA81773_F785_4A4D_8A97_1FA04FD3B458__INCLUDED_)
|