Lock a Workstation or Implement Fast User Switching With a Single Line

Category:
System/API
Type:
Snippets
Difficulty:
Intermediate
Author:
Anonymous

Version Compatibility: Visual Basic 6

More information:
The LockWorkStation function allows your program to lock the local computer, similar to pressing CTRL + ALT + DEL and clicking Lock Workstation. If the welcome screen is used, this will instead display the welcome screen for fast user switching. Just call the LockWorkStation function with no arguments. Requires user32.lib.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: