Solved

Terminating a detached process started with CreateProcess

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now