Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

End process challenge

Posted on 2003-03-07
6
Medium Priority
?
233 Views
Last Modified: 2010-04-01
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.
0
Comment
Question by:qwertypal
  • 3
  • 2
6 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 8088422
If it is a GUI app: Process 'WM_ENDSESSION' and 'WM_QUERYENDSESSION'
0
 

Author Comment

by:qwertypal
ID: 8092068
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.
0
 
LVL 2

Expert Comment

by:bkrahmer
ID: 8095633
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:qwertypal
ID: 8097586
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.
0
 
LVL 2

Accepted Solution

by:
bkrahmer earned 300 total points
ID: 8098122
From what I can tell, end process from the task manager is a brutal kill.  If it is, then the only thing you can do is checkpoint your data at time intervals.  That's what's nice about using a service on nt platforms.  You can't kill services from the task manager, so you won't have to worry about that case.

brian
0
 

Author Comment

by:qwertypal
ID: 8099926
You are right, Brian

Thank you.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

581 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