简体   繁体   中英

Windows Logoff Event c++

I need to catch windows logoff event, I'm using c++. I dont know where to start searching,

thanks for any help,

Dani.

In console application, you can register a callback ( SetConsoleCtrlHandler , CTRL_LOGOFF_EVENT ).

In message-loop application, you can catch certain messages ( WM_QUERYENDSESSION , WM_ENDSESSION ).

See Logging Off (Windows) on MSDN.

WM_QUERYENDSESSION和WM_ENDSESSION很可能就是你所追求的。

I believe the "correct" way is to listen to a WMI event.

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/0c1bded8-0cce-4260-bd28-4b4ffce0d27d

Disclaimer: I have not tried this myself.

You can use OpenInputDesktop MSDN

During logoff, the Input Desktop is inaccessible to the user, and the function retuns NULL.

ex: HDESK hDesk = OpenInputDesktop(0, FALSE, READ_CONTROL);

if (!hDesk) -- during logoff... -- else { --normal state-- CloseHandle(hDesk); }

In windows vista & 7, pressing CTRL+ALT+DELETE also brings to an inaccessible to the user desktop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM