Simple way of detecting shutdown?

R

Rich

I have a simple, single threaded program in C++ that runs as Idle
priority.
The program creates some data which needs dumping to file if the
computer is shutdown or logged out.

At the moment there is almost no Win32 code in it (only a few lines to
do the idle priority class). What is the simplest way of
programatically detecting the shutdown so I can dump my data to file?
I would rather not put masses of Win32 code in there, is there
anything, more simple than the message-loop/windowproc method?

Cheers,
Rich.
 
J

JKop

Rich posted:
I have a simple, single threaded program in C++ that runs as Idle
priority.
The program creates some data which needs dumping to file if the
computer is shutdown or logged out.

At the moment there is almost no Win32 code in it (only a few lines to
do the idle priority class). What is the simplest way of
programatically detecting the shutdown so I can dump my data to file?
I would rather not put masses of Win32 code in there, is there
anything, more simple than the message-loop/windowproc method?

Cheers,
Rich.

GetMessage I believe is the only way to go on this.

Post to:

comp.os.ms-windows.programmer.win32
microsoft.public.win32.programmer.kernel
microsoft.public.win32.programmer.ui
microsoft.public.win32.programmer.messaging
and,(this isn't a typo:)
microsoft.public.win32.programmer.messsaging

I suggest "ui" because "GetMessage" is in "User32.dll" ( I
think... )

-JKop
 
V

Victor Bazarov

Rich said:
[..OS-specific question snipped..]

Please refrain from cross-posting non-C++ language questions
to comp.lang.c++. They are off-topic here. Thank you.
 
B

BigJet

ADD this to your Window Proc, case WM_DESTROY:
-- PLACE YOUR FILE SAVE CODE
HERE -
PostQuitMessage (0)
;
return 0;

Good luck
--jet
 
R

Rich

Victor Bazarov said:
Rich said:
[..OS-specific question snipped..]

Please refrain from cross-posting non-C++ language questions
to comp.lang.c++. They are off-topic here. Thank you.

It was cross posted in case there was some C/C++ language way of doing
this I did not know about!
Perhaps using signal.h and SIGTERM?

SORRY!
 

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
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top