当资源管理器不是 shell 时启动屏幕保护程序

发布于 2024-09-18 09:57:39 字数 370 浏览 6 评论 0原文

我正在运行我自己的信息亭应用程序作为 shell(替换 HKLM/Software/Microsoft/Windows NT/winlogon/shell)。

应用程序需要能够关闭监视器,我使用 Process.Start("scrnsave.scr") 来执行此操作。它可以在我的开发机器上运行,但在更换外壳后就不行了。

显然是因为 UseShellExecute 设置为 true,但是当我将其设置为 false 时,我无法运行屏幕保护程序。使用 explorer.exe 作为命令并使用 scrnsave.scr 作为参数只会导致资源管理器窗口打开。

是否有一个开关可以传递给资源管理器以使其运行屏幕保护程序,或者是否有其他方法可以实现相同的目的?

谢谢。

I'm running my own kiosk application as the shell (replacing HKLM/Software/Microsoft/Windows NT/winlogon/shell).

The application needs to be able to turn off the monitor and I was using Process.Start("scrnsave.scr") to do this. It works on my dev machine but not when the shell is replaced.

It's clearly because the UseShellExecute is set to true, but when I set it to false I can't get the screensaver to run. Using explorer.exe as the command and scrnsave.scr as the argument just causes an explorer window to open.

Is there a switch I can pass to explorer to get it to run the screensaver or is there another way to achieve the same thing?

Thanks.

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

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

发布评论

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

评论(1

幽蝶幻影 2024-09-25 09:57:39

您可以通过向系统发送 Windows 消息来启动屏幕保护程序。

SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_SCREENSAVE, 0)

您将需要以下定义,

static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
static readonly IntPtr SC_SCREENSAVE = new IntPtr(0xf140);
const uint WM_SYSCOMMAND = 0x112;

[DllImport("User32",SetLastError=true)]
extern static int SendMessage(
  IntPtr hWnd,
  uint Msg,
  IntPtr wParam,
  IntPtr lParam);

然后可以按如下方式使用它们

SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_SCREENSAVE, IntPtr.Zero);

You can start the screen saver by sending a windows message to the system.

SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_SCREENSAVE, 0)

You will need the following definitions

static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
static readonly IntPtr SC_SCREENSAVE = new IntPtr(0xf140);
const uint WM_SYSCOMMAND = 0x112;

[DllImport("User32",SetLastError=true)]
extern static int SendMessage(
  IntPtr hWnd,
  uint Msg,
  IntPtr wParam,
  IntPtr lParam);

Which you can then use as follows

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