win2000中是NT内核,和win98的内核不同。两者关于进程的API也有很大的不同。比如取进程ID。

解决方案 »

  1.   

    我是想问怎样用DELPHI实际,不管是WIN2000或WIN98
      

  2.   

    这个问题我也想知道,谁能告诉我吗
    [email protected],谢谢!!!
      

  3.   

    谁知道,也请告诉我一下,谢谢![email protected]
      

  4.   

    代码:
    procedure TForm1.Button1Click(Sender: TObject);
    var Res: DWORD;
        H: HWND;
    begin
      H := FindWindow(nil, 'FormSomeCaption');
      if H = 0 then
        Label1.Caption := 'Window not found'
      else
        if SendMessageTimeout(H, WM_NULL, 0, 0, SMTO_NORMAL, 100, Res) <> 0
    then
          Label1.Caption := 'Responding'
        else
          Label1.Caption := 'Not responding';
    end;And to Kill it, no questions asked, then..procedure TForm1.ButtonClick(Sender: TObject);
    VAR  ProcessHandle: THANDLE;
         WinHwnd: HWND;
         ProcessID,ExitCode: INTEGER;
    begin
       ProcessID:= 0;
       ExitCode:= 0;   WinHwnd:= FindWindow(nil,'FormSomeCaption');
       if NOT(IsWindow(WinHwnd)) then
       begin
          ShowMessage('Window NOT found');
          exit;
       end;   GetWindowThreadProcessID(WinHwnd,@ProcessID);
       ProcessHandle:= OpenProcess(PROCESS_CREATE_THREAD OR
    PROCESS_VM_OPERATION
                      OR PROCESS_VM_WRITE OR PROCESS_VM_READ OR
    PROCESS_TERMINATE,
                      FALSE,ProcessID);
       if (ProcessHandle > 0) then
       BEGIN
           GetExitCodeProcess(ProcessHandle,ExitCode);
    // or  GetExitCodeProcess(ProcessHandle,DWORD(ExitCode));
           TerminateProcess(ProcessHandle,ExitCode);
           CloseHandle(ProcessHandle);
       END
       ELSE
          ShowMessage('Unable to get proccess Handle');
    end;