README.md

December 5, 2022 ยท View on GitHub

Stop a Shutdown

Description

This stops the system from shutting down when windows goes to shut down...

More Info

Submitted On
ByDan Dayon
LevelBeginner
User Rating4.8 (29 globes from 6 users)
CompatibilityVB.NET
CategoryMiscellaneous
World.Net (C#, VB.net)
Archive File

Source Code

'Constants
Private Const WM_QUERYENDSESSION As System.Int32 = &H11
Private Const WM_CANCELMODE As System.Int32 = &H1F
'And the Sub itself....
Protected Overrides Sub WndProc(ByRef m As Message)
	If m.Msg = WM_QUERYENDSESSION Then
'Check the m, if it's trying to shut down, don't send it. Send a new message cancelling it.
		Dim x As New Message
		x.Msg = WM_CANCELMODE
		MyBase.WndProc(x)
	Else
'Otherwise, just send the message.
		MyBase.WndProc(m)
	End If
End Sub