Solved

How Can You Close Down An Exe Launched With ShellExecute?

Posted on 2003-11-11
2
371 Views
Last Modified: 2010-04-05
I launch an external program in the Form Create section of my app with:

ShellExecute(0, 'Open', PChar('Other.exe'), PChar(''), PChar(''), SW_Hide);

This works perfectly, but I just found out that there were approximately 30 instances of this program running when I looked in the task manager!  Obviously, each time I run my app, another copy of the external program is run. :)

Is there any way of closing down a program launched in this way when I close my app down?

TDK_Man
0
Comment
Question by:tdk_man
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
SaLz earned 100 total points
ID: 9727344
this will work for you :)

procedure TForm1.Button1Click(Sender: TObject);
begin
PostMessage(FindWindow(Nil, 'Untitled - Notepad'), WM_QUIT, 0, 0);
end;

or

procedure TForm1.Button1Click(Sender: TObject);
begin
PostMessage(FindWindow(Nil, 'Untitled - Notepad'), WM_QUIT, 0, 0);
ShellExecute(0, 'Open', PChar('Other.exe'), PChar(''), PChar(''), SW_Hide);
end;
0
 
LVL 1

Author Comment

by:tdk_man
ID: 9727671
Thanks!

It's one of those things you forget to remember...

TDK_Man
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 2 90
Firemonkey android show image from resource ? 1 71
Wincontrol not (correctly) drawn 15 57
How to insert .png images to TClientDataSet .cds file? 2 83
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

732 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