12-17-2009, 02:06 PM
For this trigger we need a window, because OS sends WM_DEVICECHANGE message to all windows. It can be a dialog, or a toolbar, or other window, and it must exist all time. In this example I used toolbar, to avoid creating new thread. A toolbar hook function works like a window or dialog procedure. It is called every time when the toolbar receives a message.