I want to check that whether the system is in log off state or not in VC++, any ideas?
+3
A:
- You can get logon/logoff notifications using various mechanisms (SENS, SCM Notifications if your program is a service, Winlogon notification if you're on XP)
- You can use WMI to enumerate active sessions.
- You can use the WTS API to enumerate sessions and query session information.
On Freund
2009-05-12 06:22:48
i need to discuss the point WMI to enumerate active sessions point that u have mentioned. How do i use it to judge weather the machine is in log off state or not. I am using following wmi query to get the sessions.SELECT * FROM Win32_LogonSession it returns me 7 sessions where is there only one user logged in. Also LsaEnumerateLogonSessions() function does the same.
Abdul Khaliq
2009-05-12 07:48:38
Some trial and error with the LogonType property of the sessions should take care of this.
On Freund
2009-05-12 10:53:07
+3
A:
In AutoIt I always detect if the system is logged off by checking the active window handle if the system is logged of the active window handle will return 0x0000000. In AutoIt it would look something like...
If WinGetHandle("") == 0x00000000 Then MsgBox(0,"","We are logged out!")
Hope that helps...
Copas
2009-05-12 06:33:28