473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Run cleanup before the program is killed from the outside

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

Nov 22 '05 #1
3 1249
Ian
Is******@gmail.com wrote:
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
Nov 22 '05 #2

Ian skrev:
Is******@gmail.com wrote:
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

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

- Ishmagel

Nov 22 '05 #3

<Is******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

Ian skrev:
Is******@gmail.com wrote:
> 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

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
Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jon Roland | last post by:
I have a number of changes I like to make to HTML files that are not currently supported by HTML Tidy. Most of them arise from OCR recognition errors, and many from the ways my OCR program,...
10
by: Jonathan Ames | last post by:
Moving to C++ from Java, I'm still confused by some aspects of memory cleanup operations. For example, let's say I have a class MovingObject which maintains a pointer to another class...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
9
by: Mark Stijnman | last post by:
I need to use an API in our current project and I have been writing some wrapper classes for the functionality we need. Unfortunately, before you can use any API calls, the API must be initialized,...
6
by: Narshe | last post by:
If I implement IDisposable in a custom class, how do I let the GC know that the custom class objects aren't being used anymore, and are ready for cleanup? Do I just set them equal to null? Do I...
6
by: g35rider | last post by:
Hi, sometimes due to unchecked code I get segmentation faults once in a while and would like to be able to catch them and do some cleanup on things. This segmentation fault could be anywhere in the...
69
by: MQ | last post by:
Hi all I am just wondering how most people implement cleanup in C functions. In particular, if the function opens a number of resources, these need to be released properly should an error occur...
3
by: Petr Pavlu | last post by:
Hello, I have two questions how the functions should be written. I read the FAQ but didn't find any answer. If there is any please point me out. I. Cleanup code Consider I have to open file1,...
4
by: IanWright | last post by:
I've got a section of a program that I can't quite get to work. I'm fairly sure its something very simple/trivial but it looks correct to me, so if someone could help me fix the problem, and explain...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.