Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

7 May, 2024: fms is rebuilding. Don't expect much in that section for quite a few days, maybe longer.


devel / comp.os.ms-windows.programmer.win32 / Detecting Windows shutdown

SubjectAuthor
o Detecting Windows shutdownCharlie Gibbs

1
Detecting Windows shutdown

<1agtJ.153242$831.110733@fx40.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=255&group=comp.os.ms-windows.programmer.win32#255

  copy link   Newsgroups: comp.os.ms-windows.programmer.win32
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx40.iad.POSTED!not-for-mail
Newsgroups: comp.os.ms-windows.programmer.win32
From: cgibbs@kltpzyxm.invalid (Charlie Gibbs)
Subject: Detecting Windows shutdown
User-Agent: slrn/1.0.3 (Linux)
Lines: 33
Message-ID: <1agtJ.153242$831.110733@fx40.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sun, 12 Dec 2021 05:56:13 UTC
Date: Sun, 12 Dec 2021 05:56:13 GMT
X-Received-Bytes: 2167
 by: Charlie Gibbs - Sun, 12 Dec 2021 05:56 UTC

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
immediately.)

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.

aTdHvAaNnKcSe...

--
/~\ Charlie Gibbs | Life is perverse.
\ / <cgibbs@kltpzyxm.invalid> | It can be beautiful -
X I'm really at ac.dekanfrus | but it won't.
/ \ if you read it the right way. | -- Lily Tomlin

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor