Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
USB drive
Is there a way to monitor when a USB drive shows up?
I'm looking for anything at all to trigger off of. the file triggers dont seem to start monitoring untill after the files show up on the system rather than when the files show up.


if not, is there a way to have a thumb drive do a sort of autorun like a cd?
An old blog on QM coding and automation.

The Macro Hook
i use function getdrivestatus:
Drive status
does this sit and wait for a drive insertion trigger and then start? it looks like you have to run it after the drive is inserted to get the drivetype.
An old blog on QM coding and automation.

The Macro Hook
you could start a function with tim in init2
tim 3 usb_checker
that's a great idea if there isn't a way to hook into the system and use the trigger.

would there be something in here about it? it's pretty far over my head but you can probably make sense of it. ... ft05a1.asp
An old blog on QM coding and automation.

The Macro Hook
Assign this toolbar hook function to a toolbar that is open all time and it will notify when a drive is inserted and removed. Also works with CD and other. Function name is not important.

Copy      Help
function# hWnd message wParam lParam


type DEV_BROADCAST_VOLUME dbcv_size dbcv_devicetype dbcv_reserved dbcv_unitmask @dbcv_flags

sel message
,if(v.dbcv_devicetype!=DBT_DEVTYP_VOLUME) ret
,int i j=v.dbcv_unitmask
,for(i 0 26) if(j&1) break; else j>>1
,sel wParam
,,out "inserted %c" i
,,;if(i='E') mac "OnInserted"
,,out "removed %c" i
,,;if(i='E') mac "OnRemoved"
WOW! that's really nice.

i also got it to trigger off of "rundll32" process and check to make sure it was actually the drive that started it up.

Copy      Help
if WINAPI.GetDriveType("e:\")=2
do this stuff
An old blog on QM coding and automation.

The Macro Hook
Dear Gintaras,

I am using this toolbar hook function for a couple of years successfully. Neverthless, I am afraid I have not understood the way that a toolbar which is open all time can trigger this hook function. More specifically, is this function running continiously or on a special event? What forces a device broadcast signal to trigger a toolbar, which then it triggers its hook function. I would appreciate any advice if possible, at your convenience.

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.
It is a very clear explanation. Many thanks indeed.
Dear Gintaras,

Is it possible to extend this routine in the case of a portable media device, such as a Nokia E7-00 phone. I need to access its mass memory.

Thanks in advance.

Sorry for bothering : I had only to change a phone's internal setting in order to behave as USB device.

Forum Jump:

Users browsing this thread: 1 Guest(s)