取得Disk Driver List与各个Driver的型态

彩石灰

彩石灰

2016-02-19 16:52

今天图老师小编要跟大家分享取得Disk Driver List与各个Driver的型态,精心挑选的过程简单易学,喜欢的朋友一起来学习吧!

  

Private Declare Function GetDriveType Lib "kernel32" _  Alias "GetDriveTypeA" (ByVal nDrive As String) As LongPrivate Declare Function GetLogicalDriveStrings Lib "kernel32" _  Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, _  ByVal lpBuffer As String) As Long'GetDriveType()的传回值意义如下:'0  The drive type cannot be determined.'1  The root directory does not exist.'2  The drive can be removed from the drive.'3  The disk cannot be removed from the drive.'4  The drive is a remote (network) drive.'5  The drive is a CD-ROM drive.'6  The drive is a RAM disk.Private Sub Command1_Click()Dim drv() As String, i As LongDim DrvType As LongCall GetAvailDriver(drv())For i = LBound(drv) To UBound(drv)  DrvType = GetDriveType(drv(i))  Select Case DrvType   Case 2     Debug.Print drv(i), "软碟"   Case 3     Debug.Print drv(i), "硬碟"   Case 4     Debug.Print drv(i), "网路磁碟"   Case 5     Debug.Print drv(i), "光碟"   Case 6     Debug.Print drv(i), "RamDisk"   Case Else     Debug.Print drv(i), "不明"  End SelectNext iEnd Sub'取得所有可用的DiskDriver ListPublic Sub GetAvailDriver(DriverName() As String)Dim totlen As LongDim buff As String, totDrvCnt As LongDim i As Long, tmpstr As String, j As Longbuff = String(255, 0)totlen = GetLogicalDriveStrings(256, buff)'取得的值如: "a:"+Chr(0)+"c:"+Chr(0) + "d:"+Chr(0) + Chr(0)'而这个例子中传回长度(totlen)是12buff = Left(buff, totlen)totDrvCnt = 0For i = 1 To totlen  tmpstr = Mid(buff, i, 1)  If tmpstr = Chr(0) Then   totDrvCnt = totDrvCnt + 1  End IfNext iReDim DriverName(totDrvCnt - 1)j = 0For i = 1 To totDrvCnt  j = InStr(1, buff, Chr(0))  DriverName(i - 1) = Left(buff, j - 1)  buff = Mid(buff, j + 1)Next iEnd Sub

(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)
展开更多 50%)
分享

猜你喜欢

取得Disk Driver List与各个Driver的型态

编程语言 网络编程
取得Disk Driver List与各个Driver的型态

JDBC Driver写法!

编程语言 网络编程
JDBC Driver写法!

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

取得Disk Free Space与Total Space

编程语言 网络编程
取得Disk Free Space与Total Space

取得Disk Volume Information

编程语言 网络编程
取得Disk Volume Information

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

当Tomcat遭遇JBDC Driver出现 'Cannot create

Web开发
当Tomcat遭遇JBDC Driver出现 'Cannot create

当Tomcat遭遇JBDC Driver 出现 Cannot create resource instance !

Java JAVA基础
当Tomcat遭遇JBDC Driver 出现 Cannot create resource instance !

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

VB访问数据库的方案比较

VB访问数据库的方案比较

音量控制打不开怎么办

音量控制打不开怎么办
下拉加载更多内容 ↓