Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect hot plugging of monitor in a win32 application?

I need some kind of event from Windows whenever there is a monitor that's getting plugged into system. Is there any API in Windows to do that. BTW, it is an C++ application

like image 332
srs Avatar asked Sep 17 '09 17:09

srs


2 Answers

Use RegisterDeviceNotification to register for getting WM_DEVICECHANGE notification.

like image 161
Kirill V. Lyadvinsky Avatar answered Sep 27 '22 15:09

Kirill V. Lyadvinsky


You can do it via WMI, AFAIK. I've never tried it though so I can't give much help

Read here for more info: MSDN - Receiving a WMI Event

like image 25
Goz Avatar answered Sep 27 '22 17:09

Goz