Yashied Posted April 23, 2009 Share Posted April 23, 2009 (edited) How to identify a removable drive interface - USB or FireWire? Thanks. $Drive = DriveGetDrive('REMOVABLE') if IsArray($Drive) then for $i = 1 to $Drive[0] if ??? then ConsoleWrite($Drive[$i] & ' - USB') else ConsoleWrite($Drive[$i] & ' - FireWire') endif next endif Edited April 23, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
AwAke Posted April 23, 2009 Share Posted April 23, 2009 (edited) I dont know if this could be of any use but ill throw it in anyway. It was created by another member on this forum however I can not remember his name but all credit goes to him. $DBT_DEVICEARRIVAL = "0x00008000" $WM_DEVICECHANGE = 0x0219 $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colEvents = $objWMIService.ExecNotificationQuery _ ("Select * From __InstanceOperationEvent Within 5 Where " _ & "TargetInstance isa 'Win32_LogicalDisk'") While 1 $objEvent = $colEvents.NextEvent If $objEvent.TargetInstance.DriveType = 2 Then Select Case $objEvent.Path_.Class()="__InstanceCreationEvent" Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been added." & @CR) ;A Usb drive has been plugged in Case $objEvent.Path_.Class()="__InstanceDeletionEvent" ConsoleWrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been removed."& @CR) ;A usb drive has been removed EndSelect EndIf Wend Edited April 23, 2009 by AwAke Link to comment Share on other sites More sharing options...
Yashied Posted April 23, 2009 Author Share Posted April 23, 2009 I dont know if this could be of any use but ill throw it in anyway. It was created by another member on this forum however I can not remember his name but all credit goes to him. $DBT_DEVICEARRIVAL = "0x00008000" $WM_DEVICECHANGE = 0x0219 $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colEvents = $objWMIService.ExecNotificationQuery _ ("Select * From __InstanceOperationEvent Within 5 Where " _ & "TargetInstance isa 'Win32_LogicalDisk'") While 1 $objEvent = $colEvents.NextEvent If $objEvent.TargetInstance.DriveType = 2 Then Select Case $objEvent.Path_.Class()="__InstanceCreationEvent" Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been added." & @CR) ;A Usb drive has been plugged in Case $objEvent.Path_.Class()="__InstanceDeletionEvent" ConsoleWrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been removed."& @CR) ;A usb drive has been removed EndSelect EndIf WendThanks, but this is not related to my question. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Yashied Posted April 23, 2009 Author Share Posted April 23, 2009 I found the solution. expandcollapse popupconst $DRIVE_BUS_TYPE_UNKNOWN = 0x00 ; Unknown bus type const $DRIVE_BUS_TYPE_SCSI = 0x01 ; Small computer system interface (SCSI) const $DRIVE_BUS_TYPE_ATAPI = 0x02 ; AT Attachment Packet Interface (ATAPI) const $DRIVE_BUS_TYPE_ATA = 0x03 ; Advanced technology attachment (ATA) const $DRIVE_BUS_TYPE_1394 = 0x04 ; IEEE 1394 const $DRIVE_BUS_TYPE_SSA = 0x05 ; Serial storage architecture (SSA) const $DRIVE_BUS_TYPE_FIBRE = 0x06 ; Fibre channel const $DRIVE_BUS_TYPE_USB = 0x07 ; USB const $DRIVE_BUS_TYPE_RAID = 0x08 ; Redundant array of independent disks (RAID) const $DRIVE_BUS_TYPE_ISCSI = 0x09 ; iSCSI const $DRIVE_BUS_TYPE_SAS = 0x0A ; Serial-attached SCSI const $DRIVE_BUS_TYPE_SATA = 0x0B ; Serial ATA const $DRIVE_BUS_TYPE_SD = 0x0C ; Secure digital const $DRIVE_BUS_TYPE_MMC = 0x0D ; Multimedia card const $tagSTORAGE_PROPERTY_QUERY = _ 'dword PropertyId;' & _ 'dword QueryType;' & _ 'byte AdditionalParameters[4]' const $tagSTORAGE_DEVICE_DESCRIPTOR = _ 'ulong Version;' & _ 'ulong Size;' & _ 'byte DeviceType;' & _ 'byte DeviceTypeModifier;' & _ 'byte RemovableMedia;' & _ 'byte CommandQueueing;' & _ 'ulong VendorIdOffset;' & _ 'ulong ProductIdOffset;' & _ 'ulong ProductRevisionOffset;' & _ 'ulong SerialNumberOffset;' & _ 'dword BusType;' & _ 'ulong RawPropertiesLength;' & _ 'byte RawDeviceProperties[512]' func _DriveBusType($DriveLetter) local $Ret $Ret = DllCall('kernel32.dll', 'hwnd', 'CreateFile', _ 'str', '\\.\' & $DriveLetter & ':', _ 'dword', 0, _ 'dword', 0, _ 'ptr', 0, _ 'dword', 3, _ 'dword', 128, _ 'ptr', 0 _ ) if @error then return SetError(1, 0, -1) endif if $Ret[0] = 0xFFFFFFFF then return SetError(2, 0, -1) endif local $tSTORAGE_DEVICE_DESCRIPTOR = DllStructCreate($tagSTORAGE_DEVICE_DESCRIPTOR) local $tSTORAGE_PROPERTY_QUERY = DllStructCreate($tagSTORAGE_PROPERTY_QUERY) local $hDevice = $Ret[0] $Ret = DllCall('kernel32.dll', 'int', 'DeviceIoControl', _ 'hwnd', $hDevice, _ 'dword', 0x002D1400, _ 'ptr', DllStructGetPtr($tSTORAGE_PROPERTY_QUERY), _ 'dword', DllStructGetSize($tSTORAGE_PROPERTY_QUERY), _ 'ptr', DllStructGetPtr($tSTORAGE_DEVICE_DESCRIPTOR), _ 'dword', DllStructGetSize($tSTORAGE_DEVICE_DESCRIPTOR), _ 'dword*', 0, _ 'ptr', 0 _ ) if (@error) or ($Ret[0] = 0) then $Ret = -1 else $Ret = DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, 'BusType') endif DllCall('kernel32.dll', 'int', 'CloseHandle', 'hwnd', $hDevice) return SetError(3 * ($Ret < 0), 0, $Ret) endfunc; _DriveBusType MsgBox(0, 'Test', _DriveBusType('G')) My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now