Solved

How to close applications?

Posted on 1999-01-20
3
311 Views
Last Modified: 2010-04-06
How to close running application with my programm?
I am using Delphi 3.
0
Comment
Question by:kaloyan
3 Comments
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
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
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
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
 
LVL 1

Accepted Solution

by:
zwarte earned 10 total points
Comment Utility
for a very easy solution use:
application.terminate;

if you add this anywhere in you code, your application stops right there.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now