i want to get the drive letter of the newly inserted USB flash drive in the form like E:, F: .
Printable View
i want to get the drive letter of the newly inserted USB flash drive in the form like E:, F: .
Put a DriveList Box on your form and refresh the list with a TimerControl.Quote:
Originally Posted by isnoend07
EDIT: You can also refresh the list in the DriveList's Click event.
change drive_remote to drive_removablevb Code:
Dim r&, allDrives$, JustOneDrive$, pos%, DriveType& Dim aronedrive() As String allDrives$ = Space$(64) r& = GetLogicalDriveStrings(Len(allDrives$), allDrives$) allDrives$ = Left$(allDrives$, r&) aronedrive = Split(allDrives, vbNullChar) For d = UBound(aronedrive) To 1 Step -1 If getdrivetype(aronedrive(d)) = DRIVE_REMOTE Then stickid = aronedrive(d): Exit For Next
declare all the api functions and constants
it will find the removable drive with the highest drive letter
Thanks, thats what i neededQuote:
Originally Posted by westconn1
Interesting. What API is this code used with?
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As LongQuote:
Originally Posted by CDRIVE
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Const DRIVE_REMOVABLE = 2
Dunka Grazzi and thanks!!Quote:
Originally Posted by isnoend07
Have a read of API-Guide Chris. ;)Quote:
Originally Posted by CDRIVE
GetDriveType
The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.
GetLogicalDriveStrings
The GetLogicalDriveStrings function fills a buffer with strings that specify valid drives in the system.
Yeah Keith, I read the API guide after isnoend07 posted the API,s.;)Quote:
Originally Posted by Keithuk