Board index » delphi » How to kill a Windows NT process from DELPHI

How to kill a Windows NT process from DELPHI

Hi,
  Does anyone know how to kill an Windows NT process from Delphi ?

Thanks
Lenin.A.D

 

Re:How to kill a Windows NT process from DELPHI


Hi.

Quote
Asir D. Lenin wrote in message <362E4D21.60255...@mayo.edu>...
>Hi,
>  Does anyone know how to kill an Windows NT process from Delphi ?

I once made this piece of code.
Maybe it can help you.

Regards
Stig Johansen.
***************
program StopProcess;
{$APPTYPE CONSOLE}
uses
  Windows,Messages,SysUtils;

function EnumWindowsProc(WHandle: HWND; LParM: LParam): Boolean; StdCall
Export;
var
   Title, ClassName: array[0..128] of char;
   sTitle , sClass : STRING ;
begin
   Result := TRUE ;
   GetWindowText(WHandle, Title, 128);
   GetClassName(WHandle, ClassName, 128);
   sTitle := Title ;
   sClass := ClassName ;
   IF ParamCount > 0 THEN BEGIN
      Result := UpperCase(sClass) = UpperCase(ParamStr(1));
      IF ParamCount > 1 THEN
         Result := Result AND ( UpperCase(sTitle) = UpperCase(ParamStr(2)));
      Result := NOT Result ;
      IF NOT Result THEN
         PostMessage(WHandle,WM_Close,0,0);
   END ELSE
      WRITELN(sClass , '/' , sTitle,' Handle = ',WHandle );
end;

begin
   EnumWindows(@EnumWindowsProc, $0);
end.

Re:How to kill a Windows NT process from DELPHI


You can call any Windows API function directly from Delphi, including
TerminateProcess.  Note that this is not as friendly as sending a WM_CLOSE
message.

V/R
Russell L. Smith

Quote
Asir D. Lenin wrote in message <362E4D21.60255...@mayo.edu>...
>  Does anyone know how to kill an Windows NT process from Delphi ?

Other Threads