Jump to content

Retrieve all USB devices


James
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...