Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Intercept windows restart
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 Smile

Use trigger QM events -> Exit -> Windows exits. Don't know how to detect if restarting.
not tested, only found with google.
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.

Copy      Help
      'constants needed, form level
          Private Const WM_QUERYENDSESSION As System.Int32 = &H11
          Private Const WM_CANCELMODE As System.Int32 = &H1F
          'the sub to intercept the windows messages
          Protected Overrides Sub WndProc(ByRef ex As Message)
              If ex.Msg = WM_QUERYENDSESSION Then
                  'cancel the message
                  Dim MyMsg As New Message
                  MyMsg.Msg = WM_CANCELMODE
                  'send the message as normal
              End If
          End Sub
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.
i will test it on my virtual window machines.

don't be stupid as me to make experiments on a live configuration.

Forum Jump:

Users browsing this thread: 1 Guest(s)