Sign in to follow this  
Promit

Write a program to display itself and lock the screen?

Recommended Posts

I want to write a simple program that will display a window on screen, but will lock everything else so that you can't get out until you enter a password. This means Ctrl-Alt-Delete shouldn't allow you to pull up the task manager and kill process, for example, and you certainly shouldn't be able to Alt-Tab out or use any Win key tricks. How do I do this? I seem to remember some sort of trick about telling Windows that the program is a screen saver, but I don't remember any details.

Share this post


Link to post
Share on other sites
What OS? I'm assuming Windows and if you'll need to look into the Windows API. Check out the WM_SYSCOMMAND or something close to that for the list of things that you can override. Also you'll need to check from WM_KILLFOCUS and when that happens, set focus back to your window no matter what.

Share this post


Link to post
Share on other sites
On Windows NT there are things called "Desktops". Normally there are three desktops on the machine, "Default" (Where normal apps run), "Winlogon" (Where winlogon runs (The logon dialogue, ctrl-alt-del menu etc)), and "Screensaver" or something.

Winlogon uses an undocumented API to prevent other apps from switching desktop while the console is locked. This undocumented API is almost certainly only usable by Winlogon itself; there is some code preventing any other app using this undocumented API (unless Winlogon itself is completely replaced)

It's possible for normal apps to create new desktops and switch to them. However, this does not block ctrl-alt-del, which is a hotkey combination registered at system startup by Winlogon itself. Nothing else can disable it.

With Administrator access, using some dodgy techniques, it's possible to "persuade" Winlogon to do things it wasn't designed to do, such as release the desktop when it's locked. This I've managed, but it thoroughly confuses Winlogon and can easily render the console unusable.

I think your best bet would be to temporarily change the screensaver to your application, then lock the window station using the LockWindowStation (IIRC) function.

Maybe there's another way of having the screensaver explicitly activated; I think when you click on a .scr normally, it does not execute it the same way as a .exe, but instead switches to the Screensaver desktop, runs it, then switches back (I'm not completely sure about this).

Mark

PS: You can probably tell, I've done some serious research into this :)

Share this post


Link to post
Share on other sites
If you are using windows:
You may want to look into setting your program up as a password protected screen saver with a very short timmer. This way all you have to do is put up the program, then windows can handle the password and logout stuff for you. You can configure all of these settings through the registry or (I think) though Windows API function calls.

Just a thought,
Steve Kinney

Share this post


Link to post
Share on other sites
Hmmm. The thing is, I want this to basically lock the screen and display some kind of message or something when invoked. It shouldn't be a screen saver; it's meant to be run explicitly.

The specific OS is WinXP SP2, and that's the only OS it needs to work on.

Share this post


Link to post
Share on other sites
What's the purpose of your program?

If you can't find any other way, depending on the point of the program, this hack might work:

For screensaver properties, there's an option to check "On resume, display Welcome screen" which I assume is the logon screen (I can't sit still long enough to allow my screensaver to kick in :P ). Assuming you have a password set for your account, the user shouldn't be able to log back in without it. You could write a program that runs your screensaver (maybe make your own with the msg?). Assuming this is would work for your situation, a possible problem would be if you have multiple accounts for your machine, and you don't want them to get anywhere except yours or something.

EDIT: Ack, I missed a previous post that suggested the above. This might be a really stupid suggestion, but could you PrtScr and display the image as your screensaver? EDIT2: Also, what do you mean by "run explicitly"?

Share this post


Link to post
Share on other sites
Trapping Ctrl+Alt+Delete is evil; if you need to lock the computer just use the LockWorstation function.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/lockworkstation.asp

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this