Board index » delphi » View and stop processes

View and stop processes

Hi, I want to determine if a certain process is running, for instance
notepad.exe and if it's running I would like to able to stop this process
(nicely), is this possible? If so could someone show me an example of how
this is done?

Thanks Remko

 

Re:View and stop processes


Quote
"wewe" <wej...@kdfdjf.com> wrote in message

news:90j3qt$1adm6$1@reader4.wxs.nl...

Quote
> Hi, I want to determine if a certain process is running, for instance
> notepad.exe and if it's running I would like to able to stop this process
> (nicely), is this possible? If so could someone show me an example of how
> this is done?

> Thanks Remko

procedure TForm1.Button1Click(Sender: TObject);
var Wnd: HWND;
begin
  Wnd := FindWindow('Notepad',nil);
// Replace 'Notepad' with the class of the
// window you want to close.
  if Wnd<>0 then
    PostMessage(Wnd,WM_CLOSE,0,0);
end;

Other Threads