|
-
Jul 10th, 2000, 01:34 PM
#1
Thread Starter
Lively Member
hi !
i want to know how i can defin to combo box to show me the list of all the drive that the user have in his computer .
E.g : if i have in my computer the drive : a,b,c,d,e i will see in the combobox a list with all the drive type .
10x .
-
Jul 10th, 2000, 01:48 PM
#2
Why don't you use a DriveListBox?
-
Jul 10th, 2000, 01:56 PM
#3
Try this. Make a Form with a ComboBox and a CommandButton and insert the following code into the Form.
Code:
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Command1_Click()
Dim Dtype As Integer
Dim CurLetter As String
Dim DriveType As Long
'Cycle through the ASCII codes for A-Z
For Dtype = 65 To 89
'Convert the ASCII code to a letter
CurLetter = Chr(Dtype)
'The the :\ suffix to the Drive
CurLetter = CurLetter & ":\"
'Get the Drive type
DriveType = GetDriveType(CurLetter)
'If Drive exsists, then add it to the Combobox
If DriveType <> 1 Then Combo1.AddItem (CurLetter)
Next Dtype
End Sub
-
Jul 10th, 2000, 01:59 PM
#4
Hyperactive Member
You could also put this in the form load:
Code:
Private Sub Form_Load()
Dim fso, sDrives, d
Set fso = CreateObject("scripting.filesystemObject")
Set sDrives = fso.Drives
For Each d In sDrives
List1.AddItem d.DriveLetter & ":\"
Next
End Sub
-
Jul 10th, 2000, 02:00 PM
#5
PowerPoster
That's easy.. get a list of all drives available by checking each letter:
Code:
'Module
Public Const Drive_Unknown = 0
Public Const Drive_NoRootDir = 1
Public Const Drive_Removable = 2
Public Const Drive_Fixed = 3
Public Const Drive_Remote = 4
Public Const Drive_CDRom = 5
Public Const Drive_RamDisk = 6
Public Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
'Code
Dim A As Long
Dim ABC As String
Dim Temp As Long
Dim Desc As String
ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Combo1.Clear
For A = 1 To Len(ABC)
Temp = GetDriveType(Mid(ABC, A, 1) & ":\")
Desc = ""
Select Case Temp
Case Drive_Unknown
Desc = "Unknown"
Case Drive_NoRootDir
'Desc = "No root directory"
Case Drive_CDRom
Desc = "CDRom"
Case Drive_Fixed
Desc = "HD"
Case Drive_RamDisk
Desc = "Ram drive"
Case Drive_Remote
Desc = "Remote"
Case Drive_Removable
Desc = "Removable disc"
End Select
If Not Desc Like "" Then: Combo1.AddItem Mid(ABC, A, 1) & " - " & Desc
Next
-
Jul 10th, 2000, 02:01 PM
#6
PowerPoster
Hm, we all post at nearly the same time
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
|