Click here to Skip to main content
15,913,773 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Kill exe's... ( processes) Pin
adara8-May-02 1:43
adara8-May-02 1:43 
GeneralRe: Kill exe's... ( processes) Pin
Braulio Dez8-May-02 2:47
Braulio Dez8-May-02 2:47 
GeneralRe: Kill exe's... ( processes) Pin
adara8-May-02 4:24
adara8-May-02 4:24 
GeneralRe: Kill exe's... ( processes) Pin
Nish Nishant8-May-02 4:08
sitebuilderNish Nishant8-May-02 4:08 
GeneralRe: Kill exe's... ( processes) Pin
Braulio Dez8-May-02 4:19
Braulio Dez8-May-02 4:19 
GeneralRe: Kill exe's... ( processes) Pin
Chris Losinger8-May-02 4:20
professionalChris Losinger8-May-02 4:20 
GeneralRe: Kill exe's... ( processes) Pin
Braulio Dez8-May-02 4:25
Braulio Dez8-May-02 4:25 
GeneralRe: Kill exe's... ( processes) Pin
Mike Nordell9-May-02 21:20
Mike Nordell9-May-02 21:20 
My main goal is to kill non-responding exe's apps ( well EXE com servers).

Then be aware there are occasions you actually can't kill them. :-<

If there's an RPC call (synchronous) that's waiting for a response, the process you want to kill is actually "hanging" inside the kernel and can't be killed. This is one of the resons COM on Windows is hated by some of us: You can't kill a hung process!

Another way to display this would be to (disregarding what the documentation states, the docs lie) create a new file, SetFilePointer to some large value (like 2GB-1), and then SetEndOfFile.

Now do this on a disk that's not using DMA to see how a user-mode process chews away almost all available CPU. Try to kill it using e.g. TaskManager. :-<

But back to your problem: this is depending on what OS you are running under (no one can ever accuse Microsoft of "stable API's" when it comes to this).

If you're using an NT kernel OS you could use the PSAPI to EnumProcesses. Then iterate that set and OpenProcess, then EnumProcessModules and finally GetModuleBaseName to get the name of the process.

If that name fits what you want to kill you then OpenProcess(PROCESS_TERMINATE, FALSE, pid), terminate that process, and finally CloseHandle on the process handle you got from OpenProcess.

Simple, wasn't it. :-/
GeneralRe: Kill exe's... ( processes) Pin
Braulio Dez10-May-02 3:08
Braulio Dez10-May-02 3:08 
Generalslightly puzzled... Pin
l a u r e n7-May-02 23:42
l a u r e n7-May-02 23:42 
GeneralRe: slightly puzzled... Pin
Henk Groenewoud8-May-02 0:59
Henk Groenewoud8-May-02 0:59 
GeneralRe: slightly puzzled... Pin
Roger Allen8-May-02 1:15
Roger Allen8-May-02 1:15 
GeneralRe: slightly puzzled... Pin
Jonathan Craig8-May-02 4:58
Jonathan Craig8-May-02 4:58 
GeneralRe: slightly puzzled... Pin
l a u r e n8-May-02 5:07
l a u r e n8-May-02 5:07 
GeneralWTL 7.0 COM Server Pin
7-May-02 23:40
suss7-May-02 23:40 
GeneralChange size of Dialog of CFormView Pin
sanskypotov7-May-02 23:31
sanskypotov7-May-02 23:31 
GeneralRe: Change size of Dialog of CFormView Pin
l a u r e n7-May-02 23:50
l a u r e n7-May-02 23:50 
GeneralRe: Change size of Dialog of CFormView Pin
sanskypotov8-May-02 0:01
sanskypotov8-May-02 0:01 
GeneralRe: Change size of Dialog of CFormView Pin
l a u r e n8-May-02 0:20
l a u r e n8-May-02 0:20 
GeneralRunning MFC program on Chinese Win NT Pin
Einar7-May-02 22:43
Einar7-May-02 22:43 
GeneralRe: Running MFC program on Chinese Win NT Pin
Maxwell Chen7-May-02 23:07
Maxwell Chen7-May-02 23:07 
GeneralRe: Running MFC program on Chinese Win NT Pin
l a u r e n7-May-02 23:45
l a u r e n7-May-02 23:45 
GeneralRe: Running MFC program on Chinese Win NT Pin
Navin8-May-02 4:55
Navin8-May-02 4:55 
GeneralHTML Help Collection Pin
7-May-02 22:27
suss7-May-02 22:27 
GeneralPlease help with selecting item in CListView Pin
Stas7-May-02 22:12
Stas7-May-02 22:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.