Discussion:
Killing a process
(too old to reply)
unknown
2009-11-25 06:04:32 UTC
Permalink
I have an application that, under certain circumstances, doesn't shut down
properly so that I have to run Task Manager to end it..
I didn't write it.
I thought maybe I could keep tabs on it using CreateProcess( ) to run the
exe and use a Wait function to find out when it's trying to close.
For example, MsgWaitForMultipleObjects( ) will return when a message is
posted, but I don't know if I can, or how to intercept a WM_DESTROY message.
Is it possible to do it this way?

Regards,
Ron Francis
www.RonaldFrancis.com
Tom Handal
2009-11-25 06:31:30 UTC
Permalink
Hi Ron,

The message will be sent to the window of the application you
executed. You will not receive the window message.

You would have to setup a hook, which you can read about here:
http://msdn.microsoft.com/en-us/library/ms632589(VS.85).aspx

Then you could use OpenProcess (with the PROCESS_TERMINATE access
right) and TerminateProcess to kill it, as long as you have the
rights.

It would probably be best to determine why it is not shutting down in
the first place and see if you can remedy that, or contact the
developer and see if they can fix it or if they have a fix available.

Hope this helps...
Tom
Post by unknown
I have an application that, under certain circumstances, doesn't shut down
properly so that I have to run Task Manager to end it..
I didn't write it.
I thought maybe I could keep tabs on it using CreateProcess( ) to run the
exe and use a Wait function to find out when it's trying to close.
For example, MsgWaitForMultipleObjects( ) will return when a message is
posted, but I don't know if I can, or how to intercept a WM_DESTROY message.
Is it possible to do it this way?
Regards,
Ron Franciswww.RonaldFrancis.com
Ron Francis
2009-11-25 23:25:00 UTC
Permalink
[top posting to keep consistent]

Thanks Tom, I suspected a hook was the way I would have to go.
I played with hooks quite a few years ago and found them difficult then (learning to write a DLL
first).
I rarely use the program so I doubt that I'll delve into hooks again unless it is just for practice.

I believe the software is just badly written and there isn't much I can do about it.
It displays the same problem on XP and Vista.
There is a newer version that costs money, (rentware), but based on the older free version, I
wouldn't upgrade, so I wouldn't get help from the vendor.

Regards
Ron Francis
www.RonaldFrancis.com


"Tom Handal" <***@gmail.com> wrote in message news:ecd7aba5-61a5-4c87-8a5c-***@13g2000prl.googlegroups.com...
Hi Ron,

The message will be sent to the window of the application you
executed. You will not receive the window message.

You would have to setup a hook, which you can read about here:
http://msdn.microsoft.com/en-us/library/ms632589(VS.85).aspx

Then you could use OpenProcess (with the PROCESS_TERMINATE access
right) and TerminateProcess to kill it, as long as you have the
rights.

It would probably be best to determine why it is not shutting down in
the first place and see if you can remedy that, or contact the
developer and see if they can fix it or if they have a fix available.

Hope this helps...
Tom
Post by unknown
I have an application that, under certain circumstances, doesn't shut down
properly so that I have to run Task Manager to end it..
I didn't write it.
I thought maybe I could keep tabs on it using CreateProcess( ) to run the
exe and use a Wait function to find out when it's trying to close.
For example, MsgWaitForMultipleObjects( ) will return when a message is
posted, but I don't know if I can, or how to intercept a WM_DESTROY message.
Is it possible to do it this way?
Regards,
Ron Franciswww.RonaldFrancis.com
Alex Blekhman
2009-11-25 08:16:36 UTC
Permalink
This post might be inappropriate. Click to display it.
Ron Francis
2009-11-26 00:05:33 UTC
Permalink
I have an application that, under certain circumstances, doesn't shut down properly so that I
have to run Task Manager to end it..
I didn't write it.
I thought maybe I could keep tabs on it using CreateProcess( ) to run the exe and use a Wait
function to find out when it's trying to close.
As Tom already mentioned MsgWaitForMultipleObjects is intended for your process. You cannot use it
with third party process. If you launch other process from yours and want to have fine control
over its execution, then there is Job object. Look for CreateJobObject, SetInformationJobObject
functions in MSDN.
Alex
Hi Alex,
I was unfamiliar with those functions.
Interesting reading, but I couldn't see how I could use it in this case.
Thanks for drawing my attention to it though.

Ron.

Continue reading on narkive:
Loading...