Re: Closing Program Correctly On Windows Shutdown by Tony
Tony
Thu Apr 29 05:12:38 CDT 2004
This extra info isn't actually required by this OP, but I thought I'd add it
for completeness if anyone finds this thread later...
The QueryUnload event is for normal VB apps with a UI
If the program is running as a Service then it would receive a call-back
when the system was shutting down.
If the program was compiled as a console-mode application, then it could
call the SetConsoleCtrlHandler API to intercept the CTRL_SHUTDOWN_EVENT
For server-side applications, with no UI, they should receive the messages
WM_QUERYSHUTDOWN and WM_SHUTDOWN, in that order
Tony Proctor
"Rick Rothstein" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in message
news:OXfZsCdLEHA.3472@TK2MSFTNGP09.phx.gbl...
> > I was wondering, is it possible to get a program to close itself down
> > properly when it detects windows shutting down, rather than having
> windows
> > kill it, or pressing end task when the screen pops up?
> >
> > I'd like it to do something like Word or Excel does when windows shuts
> down,
> > and it pops up and asks if you want to save changes, only we wont be
> > prompting the user, when the program closes, it automatically write
> some
> > date to a database. Trouble we have at the moment is our users just
> shut
> > windows down, without exiting the program correctly, (even after we're
> > explianed what to do to them)
> >
> > We're using VB6 to program the application!
>
> Write your date to the database in either the Unload Event or the
> QueryUnload Event. You can use the UnloadMode argument of the
> QueryUnload Event to distinguish the method being used to end your
> program if you need to perform different tasks for different ways in
> which your program is being ended. You can get more detail from the help
> files.
>
> Rick - MVP
>