?
Solved

End process challenge

Posted on 2003-03-07
6
Medium Priority
?
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

762 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