以下是vb6的代码(用不上):
Const DRIVE_REMOVABLE = 2
Const DRIVE_FIXED = 3
Const DRIVE_REMOTE = 4
Const DRIVE_CDROM = 5
Const DRIVE_RAMDISK = 6
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias _
"GetLogicalDriveStringsA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long
Private Declare Function GetDriveType Lib "kernel32" Alias _
"GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Command1_Click()
Dim strMsg As String, i%, lng As Long, strDriver As String * 254, strD$, s As String
lng = GetLogicalDriveStrings(255, strDriver$) '得到所有盘符的字符串,并返回盘的数目lng
ReDim strDriveName(1 To lng) As String
Dim count As Integer
For i = 0 To lng / 4 - 1
strD$ = Mid$(strDriver$, i * 4 + 1, 3)
Select Case Val(GetDriveType(strD$))
Case DRIVE_REMOVABLE
strMsg = "可移动盘"
Case DRIVE_FIXED
strMsg = "硬盘"
count = count + 1
strDriveName(count) = strD$
s = s & Chr(10) & strD$
Case DRIVE_REMOTE
strMsg = "映射盘"
Case DRIVE_CDROM
strMsg = "光驱"
Case DRIVE_RAMDISK
strMsg = "内存虚拟盘"
Case Else
strMsg = "未知"
End Select
'Debug.Print strD$; " 是 "; strMsg
Next i
ReDim Preserve strDriveName(1 To count)
MsgBox s '这里列出本计算机的盘符
End Sub