Is there a known, reliable way to delay a user logging off once they have clicked the logout button? I am wondering about how I could go about delaying, or possibly cancelling the logout then logout through the application once the counter has expired.
Share
When a logout is about to occur, the Windows message
WM_QUERYENDSESSIONis sent to all applicaitons. An application can reply to this message with a negative answer, asking for the logoff to be cancelled.From the MDSN doc:
In .NET this functionality is exposed by the
SystemEvents.SessionEndingevent. If you set theCancelproperty ofSessionEndingEventArgstotruerequests the logoff being cancelled.The logoff part has been asked before in Log off user from Win XP programmatically in C#.