Solved

How to close applications?

Posted on 1999-01-20
3
312 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
ID: 1362488
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
ID: 1362489
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
ID: 1362490
for a very easy solution use:
application.terminate;

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 87
Working with hours 3 46
How to debug For loops? 3 45
TEMBEDDEDWB how can i change its user agent ? 8 48
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

14 Experts available now in Live!

Get 1:1 Help Now