in reply to How do I know when a USB device is inserted?
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 { ... };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I know when a USB device is inserted?
by ZJ.Mike.2009 (Scribe) on Mar 06, 2010 at 07:06 UTC | |
by Corion (Patriarch) on Mar 06, 2010 at 08:13 UTC | |
by ZJ.Mike.2009 (Scribe) on Mar 06, 2010 at 09:40 UTC | |
by Corion (Patriarch) on Mar 06, 2010 at 11:04 UTC | |
by ZJ.Mike.2009 (Scribe) on Mar 06, 2010 at 14:24 UTC |