How to Lock Windows (like “Windows + L”) from .NET?

前端 未结 2 1190
后悔当初
后悔当初 2021-01-17 13:58

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

2条回答
  •  滥情空心
    2021-01-17 14:07

    The following code can be used to Lock a Computer programmatically.

    using System.Runtime.InteropServices;
    
    [DllImport("user32.dll")]
    public static extern void LockWorkStation();
    

提交回复
热议问题