用什么函数?在Win2000中用任务管理器可以很容易看到进程号,但在Win9X下用Spy看到的16进制的进程号转换成十进制后的数字非常大,我怀疑有问题。

解决方案 »

  1.   


      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
      

  2.   

    如果进程太多了效果会不会受影响 ?比如我只想找到a.exe的进程号。
      

  3.   

    GetCurrentProcessId()获取本进程的id
      

  4.   

    但是我如何从
    BOOL EnumProcesses(
      DWORD* lpidProcess,
      DWORD cb,
      DWORD* cbNeeded
    );
    列出来的进程id中找到哪一个是a.exe的呢?
      

  5.   

    HANDLE hWnd = ::OpenProcess (PROCESS_ALL_ACCESS,FALSE,进程id ); 
    其它我就是要根据a.exe的进程号进行这个操作的
      

  6.   

    EnumProcesses  // 枚举进程号
    EnumProcessModules // 根据进程号枚举每个模块
    GetModuleFileNameEx // 得到模块的名称,如果是"a.exe"就找到了.
    OpenProcess // 打开进程,窃取进程信息和其他"破坏"工作:)
      

  7.   

    What's different between Module and Process?