Solved

How Can You Close Down An Exe Launched With ShellExecute?

Posted on 2003-11-11
2
372 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 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