| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1545 人关注过本帖
标题:敬请各位高手解决vb.net(vs2010)如何检查本计算机盘符的问题。谢谢。
只看楼主 加入收藏
HVB6
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:15
帖 子:331
专家分:561
注 册:2013-10-30
结帖率:98.41%
收藏
 问题点数:0 回复次数:0 
敬请各位高手解决vb.net(vs2010)如何检查本计算机盘符的问题。谢谢。
以下是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

搜索更多相关主题的帖子: 盘符 Const String count Case 
2017-08-03 19:15
快速回复:敬请各位高手解决vb.net(vs2010)如何检查本计算机盘符的问题。谢谢。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023687 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved