|
-
Nov 17th, 2000, 11:37 PM
#1
Thread Starter
Junior Member
Is there a way to find out how many drives a PC has?
ie:
a:,b:,c:,d:,e:
-
Nov 17th, 2000, 11:42 PM
#2
Frenzied Member
Use the DriveListBox control.
-
Nov 17th, 2000, 11:51 PM
#3
Thread Starter
Junior Member
is there a way to do it with an API?
-
Nov 18th, 2000, 10:57 AM
#4
Frenzied Member
Code:
Declare Function GetLogicalDrives Lib "kernel32.dll" () As Long
Dim driveflags As Long ' receives the flags identifying valid drives
' Tell the user which drives exist on the computer. Note how this example
' only checks up to drive D:, but it does establish the necessary pattern to use in general.
Dim driveflags As Long ' receives the flags identifying valid drives
driveflags = GetLogicalDrives()
' Test the returned value to see if drives A: through D: exist.
If (driveflags And 1) = 1 Then Debug.Print "Drive A: exists."
If (driveflags And 2) = 2 Then Debug.Print "Drive B: exists."
If (driveflags And 4) = 4 Then Debug.Print "Drive C: exists."
If (driveflags And 8) = 8 Then Debug.Print "Drive D: exists."
-
Nov 18th, 2000, 11:32 AM
#5
Lively Member
You can use the following API and routine to check for the existence and type of each drive:
API:
Code:
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Calling Code:
Code:
For i = 65 to 90
x$=GetDrive(Chr(i))
Debug.Print x$
Next i
Routine:
Code:
Public Function GetDrive(sDrive As String) As String
On Error GoTo Error_Handler:
' This routine calls the API GetDriveType. That routine will return
' a long value that equates to a description as shown.
' Sample Call: GetDrive "C"
Select Case GetDriveType(sDrive & ":\")
Case 2
GetDrive = "Removable"
Case 3
GetDrive = "Drive Fixed"
Case 4
GetDrive = "Remote"
Case 5
GetDrive = "Cd-Rom"
Case 6
GetDrive = "Ram disk"
Case Else
GetDrive = "Unrecognized"
End Select
End Function
[Edited by Jeff Carlin on 11-18-2000 at 11:43 AM]
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
|