change the display setting in windows 10

Anonymous
2020-08-10T08:02:04.377+00:00

Hi,

I have two display ports in integrated system. Based on the ports ID i need to clone or extend the displays Programatically in C++.

Is any one have an idea how to clone and extend the displays? Do we have any Windows API to do it?

I have used 'EnumDisplayDevices() function to get the display info like DeviceID(Port ID) so based on the Port ID i need to clone or extend.

I have used SetDisplayConfig() API but which doesn't take Deviced ID.

Any help would be appreciated.

Thanks,

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,427 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,538 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rita Han - MSFT 2,161 Reputation points
    2020-08-11T07:13:21.947+00:00

    Hello,

    For how to clone you can refer to this thread.

    There is a target identifier in every path. Through this target identifier you can get monitorDevicePath using DisplayConfigGetDeviceInfo. Which contains information you can find in DeviceID.

    For example:

    16963-20200811-1.png

    16886-20200811-2.png

    From above snapshots we can see the shared information DELF06B which you can use to match a target of a display path to the DeviceID.

    Code piece of getting monitorDevicePath:

    	DISPLAYCONFIG_TARGET_DEVICE_NAME configInfo;  
    	memset(&configInfo, 0, sizeof(configInfo));  
    	configInfo.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME;  
    	configInfo.header.id = pathArray[i].targetInfo.id;  
    	configInfo.header.size = sizeof(DISPLAYCONFIG_TARGET_DEVICE_NAME);  
    	configInfo.header.adapterId = pathArray[i].targetInfo.adapterId;  
    
    	LONG retVal = DisplayConfigGetDeviceInfo((DISPLAYCONFIG_DEVICE_INFO_HEADER*)&configInfo);  
    

    Thank you!

    0 comments No comments