Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hi everyone,
This time I'm asking a crazy question. I think you won't mind it. I want to write a program that reminds me something each time when I unlock the computer. How can I do it? Do I want to add the program into the startup? How would I know that a computer is unlocked? i.e. how to detect the key combination of Alt + ctrl + del only when the computer is locked?
Posted
Updated 22-Feb-11 20:33pm
v2
Comments
Sergey Alexandrovich Kryukov 23-Feb-11 2:37am    
Interesting question, my 5.
--SA

Check out WM_WTSSESSION_CHANGE on MSDN[^].
wParam == WTS_SESSION_UNLOCK

Not sure if this is send on a suspend (sleep), you may need to handle WM_POWERBROADCAST[^] as well.

For future reference, I found this by opening up Spy++ from the Visual Studio Tools menu and spying on messages sent to Visual Studio. Hit CAD and locked the computer, then unlocked the computer and looked at Spy++. WM_WTSSESSION_CHANGE with WTS_SESSION_LOCK and WTS_SESSION_UNLOCK were the only messages there.
What I am saying is that there are ways for you to find these things out for yourself.

I would strongly suggest checking out Spy++ as well as ProcExp[^], ProcMon[^] and other tools.
 
Share this answer
 
v2
Comments
aravindkrgec 23-Feb-11 4:00am    
Thank you Andrew for your suggestion.
A windows machine has at least one WindowStation[^], containing various Desktops[^].

There is at least one interactive desktop (that correspond to the user working space, containing the top-level windows) and other desktops, like the logon one (occupied by the GINA interface) and the screen saver one.
When the computer is unlocked the OS switches from the GINA to the USER desktop.
This event causes the desktop window itself to be activated and hence repainted.

Now, if your program is started in the user space, yo ucan chek periodically if the current active desktop is the one you belong or another and act when it changes.

Alternatively, you can subclass the desktop window your program runs in, and check for WM_NCACTIVATE or WM_ACTIVATE.

This is what I would try.
 
Share this answer
 
Comments
aravindkrgec 23-Feb-11 3:42am    
Thank you Emilo for your reply. But while running the program at startup, the system performance'll go down. So is there any method to catch the Alt+ctrl+del button when pressed?
Andrew Brock 23-Feb-11 6:43am    
No, and that is the point of this key sequence. The operating system will catch it an not pass it on as a security measure. It may be possible with some clever hooks, but Microsoft did try to make this not possible too.

Also, on Windows XP and earlier, you could make the Ctrl+Alt+Del just open Task Manager without going to the screen asking what to do.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900