Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Action on disk in?sertion
#1
Hi Gintaras,

i'd like to have a macro triggered by disk insertion, and to retreive information about the new inserted drive (name, serial, partition in \device\harddisk1\partition 0 form etc).

Is QM able to handle that?

Thanks
#2
You may find a solution in topic :

USB drive

Regards

Simos
#3
Thanks ssimop, i stumbled upon it while i was searching the forum, seems i did not put the correct keywords first.

It seems to work, but i struggle now to get all the information i need from hook function.
If you have clues to get disk properties, would be great...

Seem i must play with Wsh.Drive though
#4
ARRAY(Wsh.Drive) a; int i j; str s
GetDrives a
for i 0 a.len
if(a[i].IsReady)
s=a[i].VolumeName
out s
else out "%s not ready" s

did the trick, thanks a bunch mate Big Grin
#5
Just for your information I attach herewith the routine I use. You can access enough useful information through a.Drive[j].?????.

Regards

Simos
Function Removable_Device_Monitor
Code:
Copy      Help
;/
function# hWnd message wParam lParam

;Toolar Hook Function Removable_Device_Monitor assigned to Office Shortcut Bar or to any other toolbar
;091217 : MyMain Toolbar Left or Right2
str smes vN iNN dL sd sPath s
Dir d
int dt

str si.getmacro(getopt(itemid) 1)
;if ideb; out "%s : %s" NowT si
;out "%s : %s" NowT si
def WM_DEVICECHANGE  0x219
def DBT_DEVICEARRIVAL 0x8000
def DBT_DEVICEREMOVECOMPLETE  0x8004
def DBT_DEVTYP_VOLUME 0x2

type DEV_BROADCAST_VOLUME dbcv_size dbcv_devicetype dbcv_reserved dbcv_unitmask @dbcv_flags
;070318 : To avoid it running while ToDo_Init is already running, ie during startup
if(EnumQmThreads(0 0 0 "ToDo_Init")) ret

sel message
,case WM_DEVICECHANGE
,sel(wParam) case [DBT_DEVICEARRIVAL,DBT_DEVICEREMOVECOMPLETE] case else ret
,DEV_BROADCAST_VOLUME* v=+lParam
,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
,i+'A'
,sel wParam
,,case DBT_DEVICEARRIVAL
;,,out "inserted %c" i
;,,out i
,,iNN.format("%c" i)
,,smes.from(iNN ":")
;,,str s.from("Device inserted: " smes)
;,,MessageD s 5 10
,,_s.format("Device Inserted %c" i)
,,out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,int x y cx cy
,,FindSysTrayIcon("QM Tray Management" x y cx cy)
,,ShowTooltip_Smart smes 10 x y 300 7 "Device Inserted" "$user profile$\My Documents\Local Settings\sysman\Ico\diskcon48.ico"
,,
;,,Display_Message("Device inserted" smes 2)
,,DiscDrives
,,for j 0 aType.len
,,,dt=aType[j]
,,,if dt > 0 ;; Examine only drives which are ready
,,,,;out dt
,,,,dL=aDrive[j].DriveLetter
,,,,if dL=iNN
,,,,,vN=aDrive[j].VolumeName
,,,,,if StrCompare(vN "ZTEMODEM" 1)=0
,,,,,,CosModem.from(dL ":")
,,,,,,_s.format("Cosmote Modem : %s on drive %s" vN CosModem)
,,,,,,out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,,,,,break
,,,,,sd.from(iNN ":")
,,,,,sPath.from(sd "\B4All")
,,,,,if(d.dir(sPath 1)) ;;if folder exists
,,,,,,Initialise_USB
,,,,,,ToDo_Init

,,case DBT_DEVICEREMOVECOMPLETE

,,_s.format("Device removed %c" i)
,,out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
;,,out i
,,smes.format("%c:" i)
,,s.from("Device removed: " smes)
,,;MessageD s 5
,,FindSysTrayIcon("QM Tray Management" x y cx cy)
,,ShowTooltip_Smart smes 10 x y 300 7 "Device Removed" "$user profile$\My Documents\Local Settings\sysman\Ico\diskdisc48.ico"

;,,Display_Message("Device removed" smes 2)
;,,if(i='K')
,,s.left(USBp 1)
,,;out USB
,,;out i
,,if(i=s[0])
;,,,out "ToDo_init"
;,,,out s
,,,if StrCompare(USBp USBd)
,,,,_s.from(USBd " /d")
,,,,run "$system$\subst.exe" _s    
,,,USBp="**"
,,,USB=""
,,,ToDo_Init


Forum Jump:


Users browsing this thread: 1 Guest(s)