Posts: 1,271
Threads: 399
Joined: Mar 2003
is qm able to intercept windows restart ?
i just installed daemon tools (mount virtual cd/dvd),
the installer asks for restart, i said 'yes',
but then i realized that i better should have saved some files ...
it would be nice too have the last hook
thanks
Posts: 12,095
Threads: 142
Joined: Dec 2002
Use trigger QM events -> Exit -> Windows exits. Don't know how to detect if restarting.
Posts: 1,271
Threads: 399
Joined: Mar 2003
not tested, only found with google.
http://www.vbforums.com/showthread.php?t=378775
Quote: Prevent Windows Shutdown
Here is a little code snippet that prevents the windows from shutting down if your app is running, it intercepts the WM_QUERYENDSESSION message that is sent to the open windows on a system shutdown, and cancels the message.
1.
'constants needed, form level
2.
Private Const WM_QUERYENDSESSION As System.Int32 = &H11
3.
Private Const WM_CANCELMODE As System.Int32 = &H1F
4.
5.
'the sub to intercept the windows messages
6.
Protected Overrides Sub WndProc(ByRef ex As Message)
7.
If ex.Msg = WM_QUERYENDSESSION Then
8.
'cancel the message
9.
Dim MyMsg As New Message
10.
MyMsg.Msg = WM_CANCELMODE
11.
MyBase.WndProc(MyMsg)
12.
Else
13.
'send the message as normal
14.
MyBase.WndProc(ex)
15.
End If
16.
End Sub
Posts: 12,095
Threads: 142
Joined: Dec 2002
Create a dialog or window or hooked toolbar that runs all the time. In the dialog/window procedure, add case WM_QUERYENDSESSION. Read in the MSDN Library how to prevent shutdown. Or you can then autosave etc and then allow to shut down.
Or use the trigger. It does not allow to cancel shutdown, but gives some time to save etc. In either case, you will not know if restarting.
Vista has new function
dll user32 CancelShutdown
Did not try it.
See also AbortSystemShutdown. Not sure if it works in all cases.
Posts: 1,271
Threads: 399
Joined: Mar 2003
i will test it on my virtual window machines.
don't be stupid as me to make experiments on a live configuration.