English 中文(简体)
Turn off the display on remote PC
原标题:

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.

问题回答

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.

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.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签