Solved

Terminating a detached process started with CreateProcess

Posted on 2004-10-19
2
1,487 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 125 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Suggested Courses

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