我遇到了锁定Windows工作站的示例:
using System.Runtime.InteropServices;
...
[DllImport("user32.dll", SetLastError = true)]
static extern bool LockWorkStation();
...
if (!LockWorkStation())
throw new Win32Exception(Marshal.GetLastWin32Error()); // or any other thing
Run Code Online (Sandbox Code Playgroud)
这个片段有一个纯粹的托管替代方案吗?即,没有P-Invoke.