未分类--Windows API--EnumProcesses

来源:互联网 发布:winrar解压缩软件4.20 编辑:程序博客网 时间:2024/06/10 23:25

原文来自MSDN Library for Visual Studio 2008 SP1,翻译部分仅为个人观点,想要看更多信息请看MSDN,如有版权问题请联系QQ 643166601,邮件643166601@qq.com

 

EnumProcesses Function

Retrieves the process identifier for each process object in the system.
返回在系统中每个进程的进程标识符。

Syntax
BOOL WINAPI EnumProcesses(
  __out  DWORD* pProcessIds,
  __in   DWORD cb,
  __out  DWORD* pBytesReturned
);

Parameters
pProcessIds
A pointer to an array that receives the list of process identifiers.
指针指向数组接收进程标识符list。

cb
The size of the pProcessIds array, in bytes.
pProcessIds的大小以byte为单位。

pBytesReturned
The number of bytes returned in the pProcessIds array.
返回在pProcessIds数组中的字节数。

Return Value
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.
如果函数失败,返回值是零。想要获得额外错误信息请调用GetLastError。

Remarks
It is a good idea to use a large array, because it is hard to predict how many processes there will be at the time you call EnumProcesses.
使用一个大的数组是一个好主意,因为它是很难预测在调用EnumProcesses时有多少进程。

To determine how many processes were enumerated, divide the pBytesReturned value by sizeof(DWORD). There is no indication given when the buffer is too small to store all process identifiers. Therefore, if pBytesReturned equals cb, consider retrying the call with a larger array.
去确定有多少进程被列举,使用pBytesReturned的值除以sizeof(DWORD)。当buffer存储所有进程标识符太小时,没有指示。因此如果pBytesReturned等于cb,考虑重试用一个更大的数组调用。

To obtain process handles for the processes whose identifiers you have just obtained, call the OpenProcess function.
去获得进程句柄,你只能获得进程的标识符,调用OpenProcess函数

Example Code
For an example, see Enumerating All Processes or Enumerating All Modules for a Process.

Requirements
Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Header Declared in Psapi.h.
 
Library Use Psapi.lib.
 
DLL Requires Psapi.dll.
 

See Also
CreateToolhelp32Snapshot
OpenProcess
Process Information
PSAPI Functions

 

Send comments about this topic to Microsoft

Build date: 4/24/2008

0 0
原创粉丝点击