怎么用VB获取本机所有的盘符?并且获取盘符的类别,比如是硬盘、软盘、光驱、或U盘?
解决方案 »
- MSFlexGrid 控件当设置成可以按行选择时,怎样在单击列标题时不选中行
- 急急急!!马上就要毕业答辩了!commondialog另存为问题??
- 关于在VB6里实现打印预览效果?想用PictureBox来实现。
- 急救!dll文件注册出错,无法注册
- 做了一个自定义BUTTON,一个简单的问题问问!
- 两个表的查询问题,急急
- 运行错误'91'怎么解决呢?谢谢!小生新来,,没有什么分,请赐教!
- 请教:怎么用vb script脚本语言读出数据库(SQL Server2000)表中的数据?100分奉送给你!
- 我想将其他窗体中的被选中的文字(反白),发送给其他程序。。清高人指点?
- 如何实现汉字库调用
- 如何使用Command1按妞确定连接web服务器的数据库
- 入门级问题
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As LongPrivate Sub Form_Load()注释:声明变量
Dim DrvNum As Single
Dim drvName As String
Dim DrvType As Integer
Dim i As IntegerMe.AutoRedraw = True
Drive1.Visible = False注释:获取所有常规磁盘信息——
DrvNum = Asc("a") - 1
For i = 0 To Drive1.ListCount
DrvNum = DrvNum + 1
drvName = Chr(DrvNum) + ":\"
DrvType = GetDriveType(drvName)
Select Case GetDriveType(drvName)
Case 0
Me.Print "不明 " + "盘符为: " + Trim(UCase(Chr(DrvNum)))
Case 2
Me.Print "软驱 " + "盘符为: " + Trim(UCase(Chr(DrvNum)))
Case 3
Me.Print "硬盘 " + "盘符为: " + Trim(UCase(Chr(DrvNum)))
Case 4
Me.Print "网络盘 " + "盘符为: " + Trim(UCase(Chr(DrvNum)))
Case 5
Me.Print "光驱 " + "盘符为: " + Trim(UCase(Chr(DrvNum)))
Case 6
Me.Print "RamDisk " + "盘符为: " + Trim(UCase(Chr(DrvNum)))
End Select
Next iEnd Sub
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Form_Load()
Dim strSave As String
Dim drvName As String
'Set the graphic mode to persistent
Me.AutoRedraw = True
'Create a buffer to store all the drives
strSave = String(255, Chr$(0))
'Get all the drives
ret& = GetLogicalDriveStrings(255, strSave)
'Extract the drives from the buffer and print them on the form
For keer = 1 To 100
If Left$(strSave, InStr(1, strSave, Chr$(0))) = Chr$(0) Then Exit For
drvName = Left$(strSave, InStr(1, strSave, Chr$(0)) - 1)
Select Case GetDriveType(drvName)
Case 0
Me.Print "不明 " + "盘符为: " + drvName
Case 2
Me.Print "软驱 " + "盘符为: " + drvName
Case 3
Me.Print "硬盘 " + "盘符为: " + drvName
Case 4
Me.Print "网络盘 " + "盘符为: " + drvName
Case 5
Me.Print "光驱 " + "盘符为: " + drvName
Case 6
Me.Print "RamDisk " + "盘符为: " + drvName
End Select
strSave = Right$(strSave, Len(strSave) - InStr(1, strSave, Chr$(0)))
Next keer
End Sub