I use (and wrote) DBD::WMI to monitor the addition/removal of devices, but using it in a GUI program means that you'll have to use a second thread that listens to the WMI.
If you're using Win32::GUI, then yes, those messages will get sent to your top level window as well.
Looking through Win32::GUI, resp. the Win32::GUI examples, I see listview_drag_drop.pl, which hooks a message (WM_CONTEXTMENU) to a callback. I didn't find it documented anywhere, but it seems that it is a/the way to specify callbacks to window messages in Win32::GUI. I guess that the following code should issue the callback whenever a device changes:
use constant WM_ONDEVICECHANGE => 0x219; # as per http://msdn.microsof +t.com/en-us/library/aa363480%28VS.85%29.aspx $window->Hook(\&device_changed); sub device_changed { ... };
In reply to Re: How do I know when a USB device is inserted?
by Corion
in thread How do I know when a USB device is inserted?
by ZJ.Mike.2009
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |