I ran into this example for locking Windows workstation:
using System.Runtime.InteropServices;
...
[DllImport("user32.dll", SetLastError = true)]
static extern bool LockWorkStation();
...
if (!LockWorkStation())
throw new Win32Exception(Marshal.GetLastWin32Error()); // or any other thing
Is there a pure managed alternative to this snippet? Namely, without P-Invoke.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…