Hi Guys,
OK, so i need something that can listen for shutdown requests and intercept and stop them. then run some code (prompts the user) that does some magic and then closes it's self and issues a new shutdown command.
This will aparently do it, but i have no idea how to use it.
Source: Prevent Windows Shutdown - VBForums
OK, so i need something that can listen for shutdown requests and intercept and stop them. then run some code (prompts the user) that does some magic and then closes it's self and issues a new shutdown command.
This will aparently do it, but i have no idea how to use it.
Source: Prevent Windows Shutdown - VBForums
VB.NET:
'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
MyBase.WndProc(MyMsg)
Else
'send the message as normal
MyBase.WndProc(ex)
End If
End Sub