question

Nouman-8919 avatar image
0 Votes"
Nouman-8919 asked LimitlessTechnology-2700 answered

Programmatically - Cross-adapter Clone with NVIDIA and Intel

I have been using this script to optionally clone/duplicate and two displays, but this fails when doing cross adaptor cloning, for example "cloning main display (Intel adapter) to external display (Nvidia adapter)"

  1. include <iostream>

  2. include <windows.h>

  3. include <vector>

  4. int main()

  5. {

  6. UINT32 pathSize;

  7. UINT32 modeSize;

  8. GetDisplayConfigBufferSizes(QDC_ALL_PATHS, &pathSize, &modeSize);

  9. std::vector<DISPLAYCONFIG_PATH_INFO> pathArray(pathSize);

  10. std::vector<DISPLAYCONFIG_MODE_INFO> modeArray(modeSize);

  11. QueryDisplayConfig(QDC_ALL_PATHS, &pathSize, &pathArray[0], &modeSize, &modeArray[0], NULL);

  12. pathArray[1].sourceInfo.id = pathArray[0].sourceInfo.id;

  13. pathArray[1].sourceInfo.modeInfoIdx = pathArray[0].sourceInfo.modeInfoIdx;

  14. UINT8 flags = SDC_APPLY | SDC_SAVE_TO_DATABASE | SDC_ALLOW_CHANGES | SDC_USE_SUPPLIED_DISPLAY_CONFIG;

  15. SetDisplayConfig(static_cast<UINT32>(pathArray.size()), &pathArray[0], static_cast<UINT32>(modeArray.size()), &modeArray[0], flags);

  16. return 0;

  17. }

when I use :
SetDisplayConfig(0, NULL, 0, NULL, SDC_TOPOLOGY_CLONE | SDC_APPLY);

that works, but this calls the last configuration in the database but does not allow me to select displays optionally.

could you please help me with that.


windows-11windows-apiwindows-hardwarewindows-app-sdk
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

XiaopoYang-MSFT avatar image
0 Votes"
XiaopoYang-MSFT answered XiaopoYang-MSFT edited

According to CCD example pseudocode and part of the answer, you need to find out the path from the current primary(adapterId A) to targets(adapterId B). To find out the path, the previous mentioned answer tries to enable each source+target pair that contains the target(adapterId B) until one works.
Relationship of Mode Information to Path Information has a picture for explanation.
196838-image.png
Finally, It‘s important to check whether all your monitors(adapterId A &B) are available in the Display setting or not.


image.png (19.8 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hi there,

The issue could be related to Display drivers which are not allowing you to select displays optionally. Also try to enable clone mode and see if that changes the way the script functions., follow these steps to enable the clone mode.

  1. In desktop mode, right-click on the Desktop and select Graphics Properties.

  2. Click Display > Multiple Displays.
    Under Select Display Mode, click Clone Displays; for old CUI, click the drop-down arrow for Operating Mode and select Clone Display.

Hope this resolves your Query!!



--If the reply is helpful, please Upvote and Accept it as an answer–

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.