我已经知道了进程的ID ProcessInfo.hProcess
用什么函数判断他是否还存在!!

解决方案 »

  1.   

    //判别进程是否挂起
    function isHung(theWindow: HWnd; timeOut: Longint): Boolean;stdcall;
    var
      dwResult: DWord;
    begin
      Result := SendMessageTimeout(theWindow,
      WM_NULL,
      0,
      0,
      SMTO_ABORTIFHUNG Or SMTO_BLOCK,
      timeOut,
      dwResult) <> 0;
    end;
      

  2.   

    //把GetProcessIdFromWindow的值传给isHung的参数theWindowfunction GetProcessIdFromWindow(var TargetWnd:Hwnd):Dword;stdcall;export;
    var
    TargetThreadId:Dword;
    TargetProcessId:Dword;
    begin
    if iswindow(targetWnd) then
      begin
      TargetThreadId:=GetWindowThreadProcessId(TargetWnd,TargetProcessId);
      result := TargetProcessId;
      end
    else
    result:=$0;
    end;
      

  3.   

    不好意思,我吾解了你的意思。应该是:
    h:=openprocess(PROCESS_ALL_ACCESS,True,Id);MSDN里的
    Return Values
    If the function succeeds, the return value is an open handle of the specified process.
    If the function fails, the return value is NULL. To get extended error information, call GetLastError.