Take the 2-minute tour ×

I've built a program running on windows 7 to communicate with a usb device "power mate". When I leave my computer, I always press "WIN+L" to lock my computer, and when I get back, I press "CTRL+ALT+DEL" and enter my password to log in the computer. At the same time, the program is running. I'm wondering is there any windows API or something to let me use the usb device to log in the computer? (there is a button on the usb device you can push)

Thanks guys. It's just an idea when I looked my usb device and asked myself "what can I do for this little guy?". It's supposed to be fun hobby project and I'm curious to see if it's possible.

The usb device is connected to the computer all the time. And in reality, the usb device can do more than just pushing a button (the product name is "griffin powermate"). My intention is to do some custom action to unlock my computer, such as left rotate 3 turns and push a button 2 times. Anyway, this is really not meant to be a solution with strong security.

share|improve this question
No, can't mess with it. These kind of problems always have a low-tech solution: use the lock on the door instead. –  Hans Passant Sep 29 '11 at 18:57
Possible, as per David's answer, but almost certainly requiring far more effort than it is worth. :-) –  Harry Johnston Sep 29 '11 at 21:58
add comment

2 Answers

You can use the OS's log on provider API (GINA for pre-vista and credential provider for vista and onward) to use your USB device as an alternative credential instead of user name/password.

You also need a driver for the device that can talk to your log on provider and trigger a log on request when a button is pushed. You can use Windows Vista's smart card architecture as a reference.

share|improve this answer
add comment

You could possibly write a credential provider to do this but why? This would effectively give credential free access to your computer. If you want to do that then don't bother locking it in the first place.

share|improve this answer
My thought exactly. "I lock my computer when I leave it, but I want to be able to just push a button on a still-attached USB device when I come back to unlock the computer.". Why bother to lock it in the first place? Just power off the monitor instead, or use a screensaver without a password and press Space. –  Ken White Sep 29 '11 at 17:54
Not to be nit-picky, but I don't really see an API your answer here. Further, I'm not sure I agree with your statement about "credential free access", assuming you take the USB with you. The user would just be shifting responsibility from remembering something to having something. This isn't a terrible solution (although there are better ones); after all, you don't "remember" your keys to get into your house. –  mrduclaw Sep 29 '11 at 17:58
@mrduclaw The credential provider is the API. I kind of imagined that the USB device was left connected to the machine. That seemed to be inferred by the question. –  David Heffernan Sep 29 '11 at 18:04
@DavidHeffernan, my apologies, when parsing an answer I'm used to looking for a solution. In this case maybe something that looks like a function or reference (perhaps something like msdn.microsoft.com/en-us/magazine/cc163489.aspx) possibly with a brief explanation (for example, "Pre-vista use GINA, else use Credential Provider). I see that you included a solution, but as a non-native English speaker it was difficult for me to locate amid all the berating. Thanks! –  mrduclaw Sep 29 '11 at 18:55
add comment

Your Answer


