Yashied Posted May 8, 2009 Share Posted May 8, 2009 expandcollapse popupFunc _DriveGetBusType($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_PROPERTY_QUERY = DllStructCreate('dword;dword;byte[4]') Local $tSTORAGE_DEVICE_DESCRIPTOR = DllStructCreate('ulong;ulong;byte;byte;byte;byte;ulong;ulong;ulong;ulong;dword;ulong;byte[512]') 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 Switch DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, 11) Case 0x00 $Ret = 'UNKNOWN' ; Unknown bus type Case 0x01 $Ret = 'SCSI' ; Small computer system interface (SCSI) Case 0x02 $Ret = 'ATAPI' ; AT Attachment Packet Interface (ATAPI) Case 0x03 $Ret = 'ATA' ; Advanced technology attachment (ATA) Case 0x04 $Ret = '1394' ; IEEE 1394 Case 0x05 $Ret = 'SSA' ; Serial storage architecture (SSA) Case 0x06 $Ret = 'FIBRE' ; Fibre channel Case 0x07 $Ret = 'USB' ; USB Case 0x08 $Ret = 'RAID' ; Redundant array of independent disks (RAID) Case 0x09 $Ret = 'ISCSI' ; iSCSI Case 0x0A $Ret = 'SAS' ; Serial-attached SCSI Case 0x0B $Ret = 'SATA' ; Serial ATA Case 0x0C $Ret = 'SD' ; Secure digital Case 0x0D $Ret = 'MMC' ; Multimedia card EndSwitch EndIf DllCall('kernel32.dll', 'int', 'CloseHandle', 'hwnd', $hDevice) Return SetError(3 * ($Ret < 0), 0, $Ret) EndFunc ;==>_DriveGetBusType ; Example Local $Drive = DriveGetDrive('ALL') For $i = 1 To $Drive[0] ConsoleWrite(StringUpper($Drive[$i]) & ' => ' & _DriveGetBusType(StringLeft($Drive[$i], 1)) & @CR) Next 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...
KaFu Posted July 20, 2009 Share Posted July 20, 2009 Really nice function, can't believe this went down unreplied, thanks for this one Yashied ! OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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