Solved

How to close applications?

Posted on 1999-01-20
3
313 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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