You can lock a Windows PC by pressing Windows + L.
How can I lock a Windows PC using VB.NET or C#?
A short example would be helpful
Call the LockWorkStation function using PInvoke.
The following code can be used to Lock a Computer programmatically.
using System.Runtime.InteropServices; [DllImport("user32.dll")] public static extern void LockWorkStation();