Make your own free website on

Detect The Type Of The Drive

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 CommandButton (named Command1) and 1 DriveListBox (named Drive1) to your form.
'Choose in the DriveListBox the drive you want to detect, and press the button.
'Insert this code to the module :

Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" _
(ByVal nDrive As String) As Long
Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

'Insert this code to your form:

Private Sub Command1_Click()
DriveType& = GetDriveType(Drive1.Drive)
Select Case DriveType
Case 1, 3: MsgBox "Hard Disk"
Case 2: MsgBox "Floppy Drive"
Case 4: MsgBox "Remote"
Case 5: MsgBox "CD Rom"
Case 6: MsgBox "RamDisk"
End Select
End Sub

Go Back