Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 850
Dani Avatar asked Aug 08 '10 09:08

Dani


3 Answers

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.

like image 192
adf88 Avatar answered Oct 21 '22 22:10

adf88


WM_QUERYENDSESSION and WM_ENDSESSION are most likely what you're after.

like image 20
Will A Avatar answered Oct 21 '22 23:10

Will A


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.

like image 23
Agnel Kurian Avatar answered Oct 21 '22 23:10

Agnel Kurian