To close e.g. Notepad, you simply send the message WM_CLOSE to the application's main window:
procedure TForm1.Button1Click(Sender: TObject);
var Hnd: THandle;
begin
Hnd := FindWindow (PChar ('Notepad'), nil);
if Hnd > 0 then
SendMessage (Hnd, WM_CLOSE, 0, 0);
end;
0 comments:
Post a Comment