?
Solved

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

Posted on 2005-03-18
7
Medium Priority
?
172 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
[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
  • 3
7 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

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

771 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