精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>● VB和Basic>>〓〓..API 函数使用..〓〓>>进程和线程>>如何在VB中获取本机正在运行的程序(进程

主题:如何在VB中获取本机正在运行的程序(进程
发信人: i_can()
整理人: winsy(2003-03-05 15:24:58), 站内信件
【 在 zaction (cutebear) 的大作中提到: 】

Use API EnumProcesses

The EnumProcesses function retrieves the process identifier for each p
rocess object in the system. 

BOOL EnumProcesses(
  DWORD *lpidProcess,  // array of process identifiers
  DWORD cb,            // size of array
  DWORD *cbNeeded      // number of bytes returned
);

Parameters:
lpidProcess 
[out] Pointer to an array that receives the list of process identifier
s. 
cb 
[in] Specifies the size, in bytes, of the lpidProcess array. 
cbNeeded 
[out] Receives the number of bytes returned in the lpidProcess array. 


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. 

Remarks:
It is a good idea to give EnumProcesses 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 enu
merated by the call to EnumProcesses, divide the resulting value in th
e cbNeeded parameter by sizeof(DWORD). There is no indication given wh
en 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. 



--
七里

※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.102.81.208]

[关闭][返回]