views:

64

answers:

1

Hello. 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.

+1  A: 

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.

Default