I am using Windows 7. When I plug a new monitor when the PC is running, the monitor is not automatically detected. I must go to the Display->Screen Resolution and click on the Detect button in order to detect the monitor with the registry configuration.
I am searching for a way to do the same programmatically using the Windows API. So I would like to write a program that detects all connected monitors reproducing the Detect button. I tried using ChangeDisplaySettingEx
but with bad results. Any suggestions?
Select Start , then open Settings . Under System , select Display . Your PC should automatically detect your monitors and show your desktop. If you don't see the monitors, select Multiple displays , then Detect.
Detect a display If you connected another display and it isn't showing in Settings, select Start > Settings > System > Display > Rearrange your displays, then select Detect.
Windows 10 has several features and settings to support one, two, three, four, and even more monitors without the need for third-party software for the best experience.
A buggy, outdated, or corrupted graphics driver can cause problems that may prevent Windows 10 from detecting a second monitor automatically. The easiest method to fix this issue is updating, reinstalling, or downgrading the driver.
Not really a WinApi but try this utility:
C:\Windows\System32\DisplaySwitch.exe
DisplaySwitch.exe /internal - Switch to Primary only
DisplaySwitch.exe /external - Switch to Secondary only
DisplaySwitch.exe /clone - Clone desktop on both screens (Not HDCP compliant!)
DisplaySwitch.exe /extend - Extend desktop to both screens
In particular, try /extend switch, it should perform detection internally.
Not an API solution, but you can use MS's DevCon utility on the command line to scan for new hardware.
https://support.microsoft.com/en-us/kb/311272
Download it from that page, then just execute this from a cmd window:
devcon.exe rescan
You can easily create a .bat or .cmd file to run this from a link.
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