关闭远程电脑上的显示器

发布于 2024-09-02 14:18:44 字数 340 浏览 13 评论 0原文

我正在修复 Windows 远程控制(类似远程桌面)应用程序中的一些错误。 还有一个功能,您可以在远程计算机上黑屏 - 所有程序都保持运行不受影响,但查看远程 PC 显示屏的人只看到黑屏。

它是通过发送IoCtl请求IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE来实现的,该请求没有文档记录。并且这个请求在Vista及以上版本不起作用。

还有其他方法可以做我想做的事吗?

事实上,SendMessage(-1,WM_SOMMAND,SC_MONITORPOWER,2) 可以解决这个问题,但如果有人触摸键盘/鼠标,屏幕会重新打开。

I'm fixing some bugs in the application for remote control (remote desktop-like) for Windows.
And there is a feature that you can blank screen on remote machine - all the programms keep running unaffected, but the person who looks into the display on remote PC sees nothing but black screen.

It is implemented by sending IoCtl request IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE, which is undocumented. And this request does not work on Vista and above.

Are there another ways to do what I want?

In fact, SendMessage(-1,WM_SOMMAND,SC_MONITORPOWER,2) does the trick, but screen turns back on if someone toches keyboard/mouse.

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

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

发布评论

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

评论(2

甜妞爱困 2024-09-09 14:18:44

您应该能够发送 WM_SYSCOMMAND SC_MONITORPOWER设置为2。不幸的是,我没有测试能力的计算机,所以我没有尝试过。

我相信,每当您触摸鼠标/键盘时,Windows 都会尝试再次唤醒,但您应该能够捕获这些消息并重新发送 2。

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
    switch (msg){
        ...
        case WM_SYSCOMMAND:
            switch (wParam){
                case SC_MONITORPOWER:
                return 2;
            }
        break;
        ...
    }
}

请注意,这尚未经过测试。

You should be able to send a WM_SYSCOMMAND with the SC_MONITORPOWER set to 2. Unfortunately, I am not at a computer with testing abilities, so I haven't tried it out.

I believe that whenever you touch mouse/keyboard, windows tries to wake up again, but you should be able to trap those messages and resend the 2.

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
    switch (msg){
        ...
        case WM_SYSCOMMAND:
            switch (wParam){
                case SC_MONITORPOWER:
                return 2;
            }
        break;
        ...
    }
}

Please note that this is not tested.

天邊彩虹 2024-09-09 14:18:44

您可以尝试使用低级键盘和鼠标挂钩(远程桌面应用程序应该已经具备)。确保它是低级别的,即 SetWindowsHookEx(WH_KEYBOARD_LL) 和 SetWindowsHookEx(WH_MOUSE_LL )。

在您的钩子回调函数中:

  • 请勿
  • 在 LowLevelKeyboardProc(您必须实现)中调用 CallNextHookEx() return -1。对 LowLevelMouseProc 执行相同的操作。

警告:这将禁用键盘(即使它无法正常工作),直到您的代码调用 CallNextHookEx() 并在回调过程中返回 0。

You could try a low level keyboard and mouse hook (which a remote desktop app should already have). Make sure it is low level i.e. SetWindowsHookEx(WH_KEYBOARD_LL) and SetWindowsHookEx(WH_MOUSE_LL).

Inside your hook callback functions:

  • DO NOT CALL CallNextHookEx()
  • return -1 in LowLevelKeyboardProc (which you must implement). Do the same thing for LowLevelMouseProc.

WARNING: This WILL disable the keyboard (even if it doesn't work properly) until your code does call CallNextHookEx() and returns 0 in your callback procedures.

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