13. January 2009 08:48
There is no such .NET function (or at least I didn’t find). Fortunately we can use PInvoke instead.
Use this function to lock workstation’s display to protect from unauthorized use. Result of this function is the same as pressing Ctrl+Alt+Del.
- Add namespace at the top of your code:
- Declare PInvoke:
[DllImport("user32.dll", SetLastError = true)]
static extern bool LockWorkStation();
- Call this function like this:
throw new Win32Exception(Marshal.GetLastWin32Error());