锁屏的实现方法
锁屏的实现方法
一、调用API LockWorkStation
代码如下
[DllImport("user32.dll")]
private static extern void LockWorkStation();
private void buttonLockWorkStation_Click(object sender, EventArgs e)
{
LockWorkStation();
}
private static extern void LockWorkStation();
private void buttonLockWorkStation_Click(object sender, EventArgs e)
{
LockWorkStation();
}
二、通过调用系统内置程序 Rundll32.exe
System.Diagnostics.Process.Start("Rundll32.exe", "USER32.dll ,LockWorkStation");
两种方法在我的机器上都实现通过。