September 2004
Intermediate to advanced
408 pages
7h 25m
English
Have you ever configured your screensaver to require a password or, on Windows XP, to “show the Welcome screen”? I've seen some special-purpose programs that need to implement similar behavior: locking the interactive console under certain conditions. It's easy to do, so I've included it here. The function you need to call is in Win32, and it's called LockWorkstation. Here's a C# program that locks the console when run:
using System.Runtime.InteropServices;
class LockItUp {
static void Main() {
LockWorkStation();
}
[DllImport("user32.dll")]
static extern void LockWorkStation();
}
After this program runs, the default desktop will be hidden and the Winlogon desktop will be displayed. All programs ...