Spegni il pc - Logoff-Shutdown
'How to deal with logoff/shutdown.
$TYPECHECK ON
$DEFINE HWND INTEGER
Const WM_QUERYENDSESSION = &H00000011
DECLARE SUB FormWndProc (Handle AS INTEGER, _
Msg AS LONG, wParam AS LONG, lParam AS LONG)
Application.Title=""
DIM Form AS QForm, rtn AS LONG
SUB FormWndProc (Handle AS INTEGER, uMsg AS DWORD, _
Param AS LONG, lParam AS LONG)
IF uMsg=WM_QUERYENDSESSION THEN
F wParam=0 THEN
'Log Off Dialog is showing/running.
IF lParam=&H80000000 THEN
ShowMessage("Logging Off")
' If WORD is running and a "Save File?"
' Dialog pops up, press cancel = no log out.
' This program will still be running if you
' press cancel, as the Log Off wasn`t done.
ELSE
ShowMessage("Shutting Down")
' Wait about 6-10 seconds for the End Task
' Dialog then press cancel = No ShutDown.
END IF
ELSE
ShowMessage("Session Ending")
END IF
END SUB
Form.WndProc = FormWndProc
DO
DOEVENTS
LOOP
|