Close Another Application

{To programmatically close another application,

send to the application a WM_QUIT message.

"Window caption" is the caption of the

window that you are sending the message to.}

function KillApp(const sCapt: PChar) : boolean;

var AppHandle:THandle;

begin

AppHandle:=FindWindow(Nil, sCapt);

Result:=PostMessage(AppHandle, WM_QUIT, 0, 0);

end;

 

{Usage:}

if not KillApp('Window caption') then

ShowMessage('App not closed');