Jump to content
Sign in to follow this  
James

Retrieve all USB devices

Recommended Posts

James

Hey all,

I have the following which will retrieve removable devices:

Global $io_type

Func GetDevices($io_type)
;~ This function will get all USB devices and list them
    MsgBox(0, "AUSB", "AUSB will now load your USB devices." & @CRLF & "This may take some time!", 3)
    For $a = 1 To $io_type[0]
        $DriveLabel = DriveGetLabel($io_type[$a])
        GUICtrlSetData($USBDevices, StringUpper($io_type[$a]) & "\")
    Next
    GUISetState(@SW_SHOW)
EndFunc   ;==>GetDevices

Unfortunatley it also returns the A:\ drive. How can I ony get USB devices?

-James

Share this post


Link to post
Share on other sites
weaponx

DriveGetLabel requires a file path be sent to it, what is in your $io_type array?

Share this post


Link to post
Share on other sites
James

Global $Devices = DriveGetDrive("REMOVABLE") ;~ We need to get all Removable devices

GetDevices($Devices)

Func GetDevices($io_type)
;~ This function will get all USB devices and list them
    MsgBox(0, "AUSB", "AUSB will now load your USB devices." & @CRLF & "This may take some time!", 3)
    For $a = 1 To $io_type[0]
        $DriveLabel = DriveGetLabel($io_type[$a])
        GUICtrlSetData($USBDevices, StringUpper($io_type[$a]) & "\")
    Next
    GUISetState(@SW_SHOW)
EndFunc   ;==>GetDevices

Share this post


Link to post
Share on other sites
weaponx

Option 1:

#include 
Global $Devices = DriveGetDrive("REMOVABLE") ;~ We need to get all Removable devices
$RESULT = _ArraySearch ( $Devices, "a:")
If NOT @ERROR Then _ArrayDelete($Devices[$RESULT])

GetDevices($Devices)

Func GetDevices($io_type)
;~ This function will get all USB devices and list them
    MsgBox(0, "AUSB", "AUSB will now load your USB devices." & @CRLF & "This may take some time!", 3)
    For $a = 1 To $io_type[0]
        $DriveLabel = DriveGetLabel($io_type[$a])
        GUICtrlSetData($USBDevices, StringUpper($io_type[$a]) & "\")
    Next
    GUISetState(@SW_SHOW)
EndFunc   ;==>GetDevicesoÝ÷ Øêmöjëh×6#include 
Global $Devices = DriveGetDrive("REMOVABLE") ;~ We need to get all Removable devices

GetDevices($Devices)

Func GetDevices($io_type)
;~ This function will get all USB devices and list them
    MsgBox(0, "AUSB", "AUSB will now load your USB devices." & @CRLF & "This may take some time!", 3)
    For $a = 1 To $io_type[0]
        If $io_type[$a] <> "a:" Then
            $DriveLabel = DriveGetLabel($io_type[$a])
            GUICtrlSetData($USBDevices, StringUpper($io_type[$a]) & "\")
        EndIf
    Next
    GUISetState(@SW_SHOW)
EndFunc   ;==>GetDevices

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.