|
-
Jul 17th, 2008, 09:08 PM
#1
Thread Starter
PowerPoster
[RESOLVED] get usb flash drive letter
i want to get the drive letter of the newly inserted USB flash drive in the form like E:, F: .
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Jul 17th, 2008, 09:11 PM
#2
Re: get usb flash drive letter
 Originally Posted by isnoend07
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.
EDIT: You can also refresh the list in the DriveList's Click event.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jul 17th, 2008, 10:28 PM
#3
Re: get usb flash drive letter
vb 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
change drive_remote to drive_removable
declare all the api functions and constants
it will find the removable drive with the highest drive letter
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 18th, 2008, 12:55 AM
#4
Thread Starter
PowerPoster
Re: get usb flash drive letter
 Originally Posted by westconn1
vb 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
change drive_remote to drive_removable
declare all the api functions and constants
it will find the removable drive with the highest drive letter
Thanks, thats what i needed
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Jul 18th, 2008, 07:25 AM
#5
Re: get usb flash drive letter
Interesting. What API is this code used with?
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jul 18th, 2008, 11:19 AM
#6
Thread Starter
PowerPoster
Re: get usb flash drive letter
 Originally Posted by CDRIVE
Interesting. What API is this code used with?
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Const DRIVE_REMOVABLE = 2
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Jul 18th, 2008, 03:08 PM
#7
Re: get usb flash drive letter
 Originally Posted by isnoend07
Private Declare Function GetDriveType Lib "kernel32"
Dunka Grazzi and thanks!!
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jul 18th, 2008, 03:21 PM
#8
Re: get usb flash drive letter
 Originally Posted by CDRIVE
Interesting. What API is this code used with?
Have a read of API-Guide Chris.
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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Jul 18th, 2008, 04:46 PM
#9
Re: get usb flash drive letter
 Originally Posted by Keithuk
Have a read of API-Guide Chris. 
Yeah Keith, I read the API guide after isnoend07 posted the API,s.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|