'EnumDisplayDevicesW returns nonexisting dispalys
Through years I have used this
int monnum = 0;
while (1){
DISPLAY_DEVICEW info {sizeof(DISPLAY_DEVICEW)};
{auto const result = EnumDisplayDevicesW(NULL, monnum, &info, EDD_GET_DEVICE_INTERFACE_NAME);
if (result == 0) return 0;
}
DEVMODEW mode {{}, {}, {}, sizeof(DEVMODEW), 0};
{auto const result = EnumDisplaySettingsExW(info.DeviceName, ENUM_CURRENT_SETTINGS, &mode, EDS_RAWMODE);
}
printf ("Coordinates parameters for monitor %i: %i, %i.\n", monnum+1, mode.dmPosition.x, mode.dmPosition.y);
++monnum;
}
and obtained the following list of my monitors
Coordinates parameters for monitor 1: 3760, 23.
Coordinates parameters for monitor 2: 0, 0.
Coordinates parameters for monitor 3: 4960, 23.
Coordinates parameters for monitor 4: 1200, 178.
But suddenly I started to obtain the list with 12 entries, where 1,2,3 entries are still the same, entries from 4 to 11 shows the consecutive monitors with 0,0 coordinates and, finally, entry 12 shows my fourth monitor again.
Where these phantom info are strored in the Registry? How to remove them?
NOTE:
I have used this info to tune the layout of my monitors as I like when a horizontal line drawn between monitors is EXACTLY at the same level (all monitors have the very same pitch, three of them are the same model and stay pivoted while fourth one is much larger and stays normally). Then I have another snippet to set the position through ChangeDisplaySettingsExW(info.DeviceName, &mode, NULL, CDS_GLOBAL|CDS_UPDATEREGISTRY, NULL); that strongly suggest all the info is stored in the Registry. Microsoft says that it is stored in the User profile. But where exactly?
The monitors from 4 to 11 are really phantomic as the ChangeDisplaySettingsExW procedure cannot be called for them -- it just returns -2 (DISP_CHANGE_BADMODE) whatever coordinates are tried.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
