How to close applications?

How to close running application with my programm?
I am using Delphi 3.
kaloyanAsked:
Who is Participating?
 
zwarteCommented:
for a very easy solution use:
application.terminate;

if you add this anywhere in you code, your application stops right there.
0
 
kretzschmarCommented:
hi kaloyan,

if you know the WindowTitle of the App you want to close, you can do it with this code

procedure TForm1.Button1Click(Sender: TObject);
var
  TheHandle : THandle;
begin
  TheHandle := Findwindow(NIL, 'Microsoft Excel'); {Excel, no open documents}
  If TheHandle > 0 then SendMessage(TheHandle,WM_CLOSE,0,0);
end;

meikl
0
 
MadshiCommented:
If you want the program to ask the user whether the modified file shall be saved, use meikl's solution, otherwise send a WM_QUIT instead of a WM_CLOSE.

Regards, Madshi.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.