Subject: re: Win32 shutdown
From: [email-masked] (Dirk Fieldhouse)
To: [email-masked]
Date: Wed, 15 Dec 1999 19:44:57 +0000

On Wed, 15 Dec 1999 08:57:40 -0500, Jeremy Gunter <jeremy dot gunter at wabash 
dot edu> wrote: 
> I have just started using cygwin.  Very impressed so far.  I am almost done
> porting a small Linux application I had previously written, and I would
> like it to run as a service.  My question is how do I get the program to
> exit when windows shuts down without windows complaining that it can't
> shutdown the program automatically.  I don't want the user to have to
> explicitly shut down the application before exiting.

Normally you'd have a Windows application with a hidden window and a message 
loop, and a window procedure in which you'd handle WM_QUERYENDSESSION by 
returning true to indicate that you're prepared to shut down (then you get 
WM_CLOSE as normal). Search on WM_QUERYENDSESSION at M$.

If you don't have this you can create a thread that does nothing else. You'll 
have a signal handler of some sort in your ported thread that recognises when 
to shut down, and you'll send that signal from the window thread.

For a die-hard console-only, not-calling-user32.dll-at-all app, you can 
investigate the .pif attribute that allows a command window to be closed by 
Windows. I don't know how this works on NT. If your app should be persistent 
across logouts, you may also like to read about services (we may prefer daemons 
in this group) at 
http://msdn.microsoft.com/library/psdk/winbase/services_2fg3.htm and 
http://msdn.microsoft.com/library/psdk/win95/95scm_5vl9.htm

-- 
Dirk Fieldhouse                 Logica UK Limited
[email-masked]           75 Hampstead Road
c=gb;a=attmail;p=logica;        London NW1 2PL
o=LOGICA;ou1=UK;s=fieldhouse    UK
+44 (20) 7637 9111

--
Want to unsubscribe from this list?
Send a message to [email-masked]