Posts: 795
Threads: 136
Joined: Feb 2009
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
Posts: 1,058
Threads: 367
Joined: Oct 2007
You may find a solution in topic :
USB drive
Regards
Simos
Posts: 795
Threads: 136
Joined: Feb 2009
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
Posts: 795
Threads: 136
Joined: Feb 2009
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
Posts: 1,058
Threads: 367
Joined: Oct 2007
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
;/
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
|