Mega Code Archive

 
Categories / Delphi / Examples
 

Close application by window name

Title: Close application by window name Use FindWindow function, which returns handle of window, which you want to close. And after that, send WM_CLOSE message to this window. procedure TForm1.Button1Click(Sender: TObject); var MyHandle: THandle; begin MyHandle:=FindWindow(nil, 'Delphi Help'); SendMessage(MyHandle, WM_CLOSE, 0, 0); end;