I think I read that this ability was removed some time ago...
Is it still possible ?
Code: Select all
Prototype ProtoShutdownBlockReasonCreate(hWnd.i, *pwszReason)
Prototype ProtoShutdownBlockReasonDestroy(hWnd.i)
If OpenLibrary(0, "user32.dll")
Global ShutdownBlockReasonCreate.ProtoShutdownBlockReasonCreate = GetFunction(0, "ShutdownBlockReasonCreate")
Global ShutdownBlockReasonDestroy.ProtoShutdownBlockReasonDestroy = GetFunction(0, "ShutdownBlockReasonDestroy")
CloseLibrary(0)
EndIf
Procedure WindowsCallback(hWnd,uMsg,wParam,lParam)
Result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_QUERYENDSESSION
why.s = "Some file still in progress."
ShutdownBlockReasonCreate(WindowID(0), @why.s)
;result = MessageRequester("Warning", why.s+" Abort shutdown?", #PB_MessageRequester_YesNoCancel)
If #True ;result = #PB_MessageRequester_Yes
AbortSystemShutdown_(#Null)
ProcedureReturn #False
Else
ShutdownBlockReasonDestroy(WindowID(0))
ProcedureReturn #True
EndIf
Case #WM_NCACTIVATE
ProcedureReturn #True
EndSelect
ProcedureReturn Result
EndProcedure
If OpenWindow(0,0,0,200,100,"Shutdown and wait")
SetWindowCallback(@WindowsCallback())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf