views:

17

answers:

1

Please help me to find a way to track lock/unlock time on my WinXP machine. I've tried windows scheduler - it only logs logins, not locks. Any alternatives?

In Miranda's source code I saw implementation via IdleObject tracker, but this way is too long. May be an AutoIt script? Time tracking program (freeware)?

A: 

If you have a Windows service you can get notification of login/logout/lock/unlock events via the OnSessionChange method. In C# you would do this:

 protected override void OnSessionChange(SessionChangeDescription changeDescription)
 {
        switch (changeDescription.Reason)
        {
            case SessionChangeReason.SessionLogon:
                //Logon
                break;
            case SessionChangeReason.SessionLogoff:
                //Logoff
                break;
            case SessionChangeReason.RemoteConnect:
                //Remote Connect
                break;
            case SessionChangeReason.RemoteDisconnect:
                //Remote Disconnect
                break;
            case SessionChangeReason.SessionLock:
                //lock
                break;
            case SessionChangeReason.SessionUnlock:
                //Unlock
                break;
            default:
                break;
        }
 }
TheCodeKing
Thanks for the hint! Can I use this snippet from within a script, e.g. VB?
Croot
Well you need to create a Windows service to get the OnSessionChange hook, so you couldn't use this technique from a VB script directly. You could however implement a Windows service in VB though.
TheCodeKing