C#:如何防止笔记本电脑进入待机状态

发布于 2024-07-17 18:51:11 字数 151 浏览 6 评论 0原文

我怎样才能在 C# 程序中做到这一点? 我很确定这应该是可能的,因为例如各种媒体程序都会这样做,因此计算机在观看电影等时不会进入待机状态。

因此,如果我创建一个简单且基本的 WinForm 应用程序,只要此应用程序正在运行,我需要做什么才能防止笔记本电脑进入待机状态?

How can I do this in a C# program? I'm pretty sure it should be possible, since various media programs for example do this so the computer doesn't go into stand-by while watching a movie, etc.

So, if I for example create a plain and basic WinForm application, what do I need to do to prevent a laptop from going into Stand-By as long as this application is running?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

祁梦 2024-07-24 18:51:11

我认为你必须 P/Invoke。 但不要害怕...这很容易。

SetThreadExecutionState 是您的朋友。 可在PInvoke 项目,也可在 NuGet

I think you'll have to P/Invoke. But don't be scared... it's pretty easy.

SetThreadExecutionState is your friend. It's available in the PInvoke project, also available on NuGet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文