Run cleanup before the program is killed from the outside

I

Ishmagel

Hi.

I have made a c++ program to be run on a computer (duh!). I set it to
be run with Windows Scheduler, and ticked the box saying: "Stop the
task if it runs for x hours and y minutes"

The program itself is running an infinite loop. My problem is that when
windows shuts it down, the program pops up with the "End Now?" dialog.
I would therefore like to do some last minute panic cleanup. So my
question is: is there a way for the c++ program to know it is about to
be shutdown from the outside? I only need to run one line of cleanup
code to make it all work

P.S.: I am aware that i might have posted to the wrong newsgroup, but i
think it is a generic c++ solution
 
I

Ian

Hi.

I have made a c++ program to be run on a computer (duh!). I set it to
be run with Windows Scheduler, and ticked the box saying: "Stop the
task if it runs for x hours and y minutes"

The program itself is running an infinite loop. My problem is that when
windows shuts it down, the program pops up with the "End Now?" dialog.
I would therefore like to do some last minute panic cleanup. So my
question is: is there a way for the c++ program to know it is about to
be shutdown from the outside? I only need to run one line of cleanup
code to make it all work

P.S.: I am aware that i might have posted to the wrong newsgroup, but i
think it is a generic c++ solution

You have, how a process is terminated is OS specific.

Ian
 
M

Mike Wahler

Ian skrev:

Okay, where should i then direct my question, please?

Many Windows experts answer questions about Windows at newsgroup
comp.os.ms-windows.programmer.win32

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top