如何在 Windows 中锁定屏幕?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4259571/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to lock the screen in Windows?
提问by gennad
Usually I develop in Java but now I need to write an app that will block the whole computer's screen every X minutes for Y minutes. It needs to make a break (I want to have a similar app in Windows like in Linux).
So I suggest I need to use C++ and User32.dll to achieve it? Am i right? (I don't want to develop an application in C#). Could anybody give me an idea which methods to use to lock the screen, I'm a newby in WinAPI developing.
Thank you!
通常我用 Java 开发,但现在我需要编写一个应用程序,每 X 分钟阻止整个计算机的屏幕 Y 分钟。它需要休息一下(我想在 Windows 中像在 Linux 中一样有一个类似的应用程序)。
所以我建议我需要使用 C++ 和 User32.dll 来实现它?我对吗?(我不想用 C# 开发应用程序)。谁能告诉我使用哪些方法来锁定屏幕,我是 WinAPI 开发的新手。
谢谢!
回答by kwantam
Just link your application to user32.dll
and call the LockWorkStation()
function directly.
只需将您的应用程序链接到user32.dll
并LockWorkStation()
直接调用该函数即可。