'Cpp Detect connected monitor in windows 10
I have 2 projectors, usually disconnected from the electricity. For play videos I am using KODI to play videos. He has sources C++ available that I process for my needs.
When running KODI, I switch screens to extended mode.
SetDisplayConfig( 0, NULL, 0, NULL, SDC_TOPOLOGY_EXTEND | SDC_APPLY );
But this only works if both screens are detected by the system. In a situation where the screens are not detected by the system, I have to enter the display settings and click "detection" before running KODI.
How to do this detection in C++?
I tried:
bool IsDisplayConnected(int displayIndex)
{
DISPLAY_DEVICE device;
device.cb = sizeof(DISPLAY_DEVICE);
return EnumDisplayDevices(NULL, displayIndex, &device, 0);
}
IsDisplayConnected(0);
IsDisplayConnected(1);
But nothing is happening. The system does not try to detect the screens.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

