By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,824 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,824 IT Pros & Developers. It's quick & easy.

Simple way of detecting shutdown?

P: n/a
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.
Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

Jul 22 '05 #2

P: n/a
Rich wrote:
[..OS-specific question snipped..]


Please refrain from cross-posting non-C++ language questions
to comp.lang.c++. They are off-topic here. Thank you.
Jul 22 '05 #3

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

Good luck
--jet
"Rich" <ri**********@supanet.com> wrote in message
news:2c*************************@posting.google.co m...
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.

Jul 22 '05 #4

P: n/a
Victor Bazarov <v.********@comAcast.net> wrote in message news:<PN****************@newsread1.dllstx09.us.to. verio.net>...
Rich wrote:
[..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!
Jul 22 '05 #5

P: n/a
Rich wrote:
What is the simplest way of programatically detecting the shutdown


Check for the WM_ENDSESSION message -- it means Windows is going bye-bye.
http://msdn.microsoft.com/library/en...endsession.asp
Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.