?
Solved

Terminating a detached process started with CreateProcess

Posted on 2004-10-19
2
Medium Priority
?
1,503 Views
Last Modified: 2013-11-20
I am trying to terminate a process that I created using CreateProcess.  I called:

if (CreateProcess(NULL, exeString, NULL, NULL, false, DETACHED_PROCESS, NULL, NULL, &startupInfo, &procInfo) == 0) ......

I then try to call TerminateProcess using the procInfo.hProcess handle.  Everytime I do this I get an "invalid handle" error.  Do I need to create the process with different flags?  I am doing this on a Windows NT machine.  The documentation says that the handle must have PROCESS_TERMINATE access.  How do I give the handle this access?
0
Comment
Question by:mromeo
[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 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 12348145
Having created process ID in  procInfo.dwProcessId use OpenProcess function with PROCESS_TERMINATE flag. After this call TerminateProcess. Possibly procInfo.hProcess handle doesn't have PROCESS_TERMINATE access.
0
 

Author Comment

by:mromeo
ID: 12350152
Perfect.  Thank you.
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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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, 8 hours left to enroll

741 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