I want to programmatically switch between following two modes:
I already tried to use the SetDisplayConfig
Function, but failed. With following command it is possible to clone the main monitor to all attached displays:
SetDisplayConfig(0, null, 0, null,
SetDisplayConfigFlags.SDC_TOPOLOGY_CLONE | SetDisplayConfigFlags.SDC_APPLY);
Unfortunately I need to duplicate secondary monitors!
I found another approach in question How to make clone or extended mode. But I can't getting it working to set the source for different display to the same reference.
Working Solution for Windows 7:
To clone/duplicate the desktop between two (or more) connected devices, all you have to do is to:
Share the 'sourceInfo.id' and 'sourceInfo.modeInfoIdx' for all 'PathInfoArray'-Items which you want to duplicate the desktop. e.g. duplicate display 'index 1' to Display with Index '2 and 3':
SetDisplayConfig()
To Extend the Display between two or more Displays (if displays are cloned), it is a little more trickier:
Extend PathInfoArray for one of the cloned displays to point to the Additional 'SourceModeInfo' - Item:
SetDisplayConfig()
This just works for Win7.
On Windows 10 RS1 onwards the SetDisplayConfig() will fail with invalid parameter. I'm not quite sure why, but i recognized that under Windows 10 the 'ModeInfo.adapterId' (low and high part) changes on each reboot. Additonaly the adapter changes when you duplicate/extend via "Windows-Settings -> Display". That's why I believe under Windows 10 you have to adjust the adapterid for PathModeInfoArray and SourceModeInfoArray as well.
Problem for now: I don't know how to get the right Adapter id for that purpose. I would be very appreciate if anyone has an answer/tip for solving this problem under windows 10. (I need a working solution for windows 10 :-( )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With