Thursday 29 October 2009

Windows messages for workstation lock/unlock and other events

Have you ever wanted to write a program which could take some action based on common user activities like logging on and off, locking or unlocking the computer etc. If yes then what you need is WM_WTSSESSION_CHANGE. Its a windows message which can be intercepted to determine if the user has locked the workstation and gone for lunch, among other things.

But before you run off to code your latest earth shattering application you need to know that you will not receive this message in your windows message queue unless you opt in i.e. you need to call WTSRegisterSessionNotification and tell windows that you are interested in receiving these messages.

Some applications which I can think of off the top of my head are...
1. Write an app to change the status message of your favorite chat client
2. Maintain a record of user login/logout/lock/unlock times

Please feel free to chip in with your own ideas.

Bye for now.

No comments:

Post a Comment