Solved

KILLING A PROCESS in VC++

Posted on 1998-05-12
6
1,074 Views
Last Modified: 2013-12-03
I want to kill a concrete proccess but i don´t know which function i have to use. I´ll get the process PID but the kill call, does not exist (like it does in UNIX). Exist any function that realize the same function that kill call  do in UNIX?
How can i do that?
I hope somebody help me.
Thanks.
0
Comment
Question by:jgonzalez
  • 4
  • 2
6 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 100 total points
ID: 1401272
Answer coming.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1401273
If you have to, you can use TerminateProcess() to kill a process.  However this is a last resort sort of measure.  It only does a partial cleanup.  If the process uses DLLs they may not be detached from the process and will continue to use resources until the system is rebooted.  

Dependong on what you want to do, there might be a better way.  What is it you want to do?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1401274
TerminateProcess uses a process handle.  If you have the process ID but not the handle, use OpenProcess() to get the handle.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:jgonzalez
ID: 1401275
I just have a bacht program in which is running a service program ( exe program), when i want to stop the services to update a data base, i´ll close ( by code) the bacht program but the service is still running( viewing the NT task manager), i want kill this program.
i use  the bacht program but in case of  service shutdown( by somethig "strange")  it starts himself again
0
 
LVL 22

Expert Comment

by:nietod
ID: 1401276
I don't understand your explanation completely.

However, there is probably a better way than TerminateProcess.  You could use an event (See CreateEvent()).  One program could signal the event when ot wants the  other program to terminate.  The other program terminates when it finds that the event is signaled.  
0
 

Author Comment

by:jgonzalez
ID: 1401277
OK the first way works fine.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

679 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