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

前端 未结 2 1188
后悔当初
后悔当初 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

    Call the LockWorkStation function using PInvoke.

    0 讨论(0)
  • 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();
    
    0 讨论(0)
提交回复
热议问题