?
Solved

Terminating a detached process started with CreateProcess

Posted on 2004-10-19
2
Medium Priority
?
1,523 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
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

Industry Leaders: 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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

839 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