请问为什么出错?
ghat-gpt 告诉我的, 本机验证可用
using System;
using System.Runtime.InteropServices;
class Program
{
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool LockWorkStation();
static void Main()
{
// 调用 LockWorkStation 函数锁定工作站
if (LockWorkStation())
{
Console.WriteLine("Workstation locked successfully.");
}
else
{
Console.WriteLine("Failed to lock the workstation. Error code: " + Marshal.GetLastWin32Error());
}
}
}
用你这个可以,谢谢!
我也找到问题所在了,我LockWorkStation写错了。L与W、S用了小写,改为大写就行了