Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Terminating a detached process started with CreateProcess

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

Technology Partners: 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: 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: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

647 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