From Charlie Gibbs@21:1/5 to All on Sun Dec 12 05:56:13 2021
I've written a program that does data collection. Normally it runs
as long as Windows is up, although it can receive a command via a
TCP/IP connection to tell it to do an orderly shutdown. The program
also checks for a WM_QUERYENDSESSION message; in this case it displays
a message box asking the user if it's OK to shut down. (I'm thinking
of removing this message box and just doing an orderly shutdown
This program is normally started and shut down by another program
which manages various facilities in our system. The problem comes
when this manager program is running as a service, which makes my
program run as a service as well. It's a GUI program, so it can't
display anything on the screen this way, but at least the Windows message-passing mechanism works properly for such things as timer
ticks. The problem is that when Windows is shut down or restarted,
I don't get a WM_QUERYENDSESSION message - when I log the message
stream I see WM_TIMER messages, but then the program is silently
killed without having the chance to flush buffers, close files,
and clean up after itself. This can result in data loss.
Is there any way to coax Windows to send me a WM_QUERYENDSESSION
message when I'm running as a service? Or is there some other way
I can determine when Windows is shutting down?
The program is written in C and uses the standard Win32 API.
/~\ Charlie Gibbs | Life is perverse.
\ / <firstname.lastname@example.org> | It can be beautiful -
X I'm really at ac.dekanfrus | but it won't.
/ \ if you read it the right way. | -- Lily Tomlin