I have a need to find the USB attached to a PC, where I know there will be only one or zero attached USB drives. So I do this ...
If I wanted to open it, I could do this ...
Nothing original here on my part, just a modification of something I found on the forums.
Code:
Function GetUBSDriveLetter() As String Local i As Long, sDrives As String 'buffer to hold return from API sDrives = String$(104," ") 'size the buffer - '"c:\" + nul = 4 bytes x 26 possible letter drives = 104 GetLogicalDriveStrings 1044, ByVal StrPtr(sDrives) For i = 65 To 90 If InStr(sDrives, Chr$(i)) And GetDriveType(Chr$(i)+":\") = %drive_removable Then Function = Chr$(i) : Exit Function Next i End Function
Code:
ShellExecute(hDlg,"Open",GetUSBDriveLetter + ":\", $Nul, $Nul, %SW_Restore)
Comment