Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

how to kill child exe...when parent exe  exists

Posted on 2005-03-18
7
Medium Priority
?
195 Views
Last Modified: 2013-11-20
hi all,....

if i hav invoked exe2 from exe1.....
i hav to kill exe2 when exe1 exists...
how can i do that...


Regards
yateesh.
0
Comment
Question by:yateesh
  • 3
4 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 13581221
0
 

Author Comment

by:yateesh
ID: 13642749
hi AlexFM

iam using shell execute to run my child exe...
but the article you suggested needs the process ID..but how can i get the process ID of the child exe when it is being invoked,...????

Regards
yateesh
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 400 total points
ID: 13642791
Replace ShellExecute with ShellExecuteEx. This function fills SHELLEXECUTEINFO::hProcess parameter with handle of created process. You can see that TerminateApp function from Microsoft article uses dwPID parameter to get process handle:
hProc = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE,  dwPID);

In this case you already have process handle. You can use it directly or get ID from it using GetProcessId API.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16293048
I think my answer is OK.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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 is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

572 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