Platform SDK: Performance Monitoring EnumProcessesThe EnumProcesses function retrieves the process identifier for each process object in the system. BOOL EnumProcesses( DWORD* lpidProcess, DWORD cb, DWORD* cbNeeded );Parameters lpidProcess [out] Pointer to an array that receives the list of process identifiers. cb [in] Size of the lpidProcess array, in bytes. cbNeeded [out] Number of bytes returned in the lpidProcess array. Return Values If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.Res It is a good idea to specify a large array of DWORD values, because it is hard to predict how many processes there will be at the time you call EnumProcesses. To determine how many processes were enumerated by the call to EnumProcesses, divide the resulting value in the cbNeeded parameter by sizeof(DWORD). There is no indication given when the buffer is too small to store all process identifiers.To obtain process handles for the processes whose identifiers you have just obtained, call the OpenProcess function.Example Code For an example, see Enumerating All Processes or Enumerating All Modules for a Process.Requirements Client: Included in Windows XP, Windows 2000 Professional, and Windows NT Workstation 4.0. Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server 4.0. Header: Declared in Psapi.h. Library: Use Psapi.lib. See Also Process Status Helper Overview, PSAPI Functions, OpenProcessPlatform SDK Release: February 2003 What did you think of this topic? Order a Platform SDK CD Requirements Client: Included in Windows XP, Windows 2000 Professional, and Windows NT Workstation 4.0. Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server 4.0. Header: Declared in Psapi.h. Library: Use Psapi.lib.See Also Process Status Helper Overview, PSAPI Functions, OpenProcess
Platform SDK: Performance Monitoring
EnumProcessesThe EnumProcesses function retrieves the process identifier for each process object in the system.
BOOL EnumProcesses(
DWORD* lpidProcess,
DWORD cb,
DWORD* cbNeeded
);Parameters
lpidProcess
[out] Pointer to an array that receives the list of process identifiers.
cb
[in] Size of the lpidProcess array, in bytes.
cbNeeded
[out] Number of bytes returned in the lpidProcess array.
Return Values
If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.Res
It is a good idea to specify a large array of DWORD values, because it is hard to predict how many processes there will be at the time you call EnumProcesses. To determine how many processes were enumerated by the call to EnumProcesses, divide the resulting value in the cbNeeded parameter by sizeof(DWORD). There is no indication given when the buffer is too small to store all process identifiers.To obtain process handles for the processes whose identifiers you have just obtained, call the OpenProcess function.Example Code
For an example, see Enumerating All Processes or Enumerating All Modules for a Process.Requirements
Client: Included in Windows XP, Windows 2000 Professional, and Windows NT Workstation 4.0.
Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server 4.0.
Header: Declared in Psapi.h.
Library: Use Psapi.lib.
See Also
Process Status Helper Overview, PSAPI Functions, OpenProcessPlatform SDK Release: February 2003 What did you think of this topic?
Order a Platform SDK CD Requirements
Client: Included in Windows XP, Windows 2000 Professional, and Windows NT Workstation 4.0.
Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server 4.0.
Header: Declared in Psapi.h.
Library: Use Psapi.lib.See Also
Process Status Helper Overview, PSAPI Functions, OpenProcess
BOOL EnumProcesses(
DWORD* lpidProcess,
DWORD cb,
DWORD* cbNeeded
);
列出来的进程id中找到哪一个是a.exe的呢?
其它我就是要根据a.exe的进程号进行这个操作的
EnumProcessModules // 根据进程号枚举每个模块
GetModuleFileNameEx // 得到模块的名称,如果是"a.exe"就找到了.
OpenProcess // 打开进程,窃取进程信息和其他"破坏"工作:)