Link to home
Start Free TrialLog in
Avatar of qwertypal
qwertypal

asked on

End process challenge

Dear experts,

I have a task to write a program that will be started
from the registry (Run) and ended with the Shut Down. The
problem is that I need to end the execution of the program gracefully, as it will do a lot of calculations, it needs
to save its data before the Shut Down.

It'd be also great if there was a way to save all data when user tries to terminate the process from the Task
Manager.

The program should be able to run on most Windows platforms.

I appreciate your help.
Q.
Avatar of jkr
jkr
Flag of Germany image

If it is a GUI app: Process 'WM_ENDSESSION' and 'WM_QUERYENDSESSION'
Avatar of qwertypal
qwertypal

ASKER

Actually, my app is an API executable that runs without any windows. On Terminate Process from Task Manager
it doesnt seem to receive any messages, nor at Shut Down.
Is there still a way to capture those messages?

I would've implemented this app as a Service, but my goal was to make it run on most Windows platforms.

Q.
First of all, I would abstract my startup and shutdown, and actually make it a service on nt/2k/xp.  Secondly, on win9x, I think what you can do is create a window which is not visible.  That should allow you to catch the messages that you will need.  There's more info here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/system_shutdown.asp

brian
Thanks, Brian, that helped.

What about when a user tries to end the process from the Task Manager? I suppose no messages get posted in this case, right?

Q.
ASKER CERTIFIED SOLUTION
Avatar of bkrahmer
bkrahmer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You are right, Brian

Thank you.