可能重复:
在C#中以编程方式锁定Windows工作站
我目前正在开发一个Visual Studio Windows窗体应用程序,它需要一个锁定工作站的功能.当调用该函数时,如何使用user32.dll进行锁定(Windows + L)?
Pac*_*ane 38
我自己没试过,但我在谷歌上发现了这个
Process.Start(@"C:\WINDOWS\system32\rundll32.exe", "user32.dll,LockWorkStation");
编辑:我试过了,它的确有效!
edit2:这是一个使用它的解决方案user32.dll,不会启动外部进程.
using System.Runtime.InteropServices;
声明一个这样的方法:
[DllImport("user32.dll")]
public static extern bool LockWorkStation();
Run Code Online (Sandbox Code Playgroud)
然后打电话LockWorkStation();.
瞧
| 归档时间: |
|
| 查看次数: |
14293 次 |
| 最近记录: |