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

2016-02-19 16:52 2 1 收藏

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

【 tulaoshi.com - 编程语言 】

  

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://www.tulaoshi.com/bianchengyuyan/)

来源:http://www.tulaoshi.com/n/20160219/1613381.html

延伸阅读
ListBox窗口用来列出一系列的文本,每条文本占一行。创建一个列表窗口可以使用成员函数: BOOL CListBox::Create( LPCTSTR lpszText, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff ); 其中dwStyle将指明该窗口的风格,除了子窗口常用的风格WS_CHILD,WS_VISIBLE外,你可以针对列表控件指明专门的风格。 LBS_M...
首先IList 泛型接口是 ICollection 泛型接口的子代,并且是所有泛型列表的基接口。 它仅仅是所有泛型类型的接口,并没有太多方法可以方便实用,如果仅仅是作为集合数据的承载体,确实,IListT可以胜任。 不过,更多的时候,我们要对集合数据进行处理,从中筛选数据或者排序。这个时候IListT就爱莫能助了。 1、当你只想使用接口的方法时,ILis...
列表控件可以看作是功能增强的ListBox,它提供了四种风格,而且可以同时显示一列的多中属性值。MFC中使用CListCtrl类来封装列表控件的各种操作。通过调用 BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );创建一个窗口,dwStyle中可以使用以下一些列表控件的专用风格: LVS_ICON LVS_SMALLICON LVS_LIST L...
标签: Web开发
原来工作中曾经碰到过UL列表里一些异常的表现, 加上昨天看到了http://bbs.blueidea.com/thread-2984871-1-1.html 这个贴子,所以测试了一下list-style的各种属性,发现了一个有意思的现象 先看一下CSS手册中,对于list-style的解释 定义和用法 list-style 简写属性在一个声明中设置所有的列表属性。       ...
win7系统开机提示“Non-system disk or disk error”   具体原因分析:对于win7操作系统来说,这种故障主要是出现在硬盘存在100MB隐藏分区的电脑上,这是由于隐藏的100MB分区保存着Win7系统的引导文件,而且默认情况下,是活动主分区,当用户在磁盘管理中误将当前c盘设置为活动分区的时候,就会在开机的时候出现找不到活动主分区的...

经验教程

19

收藏

58
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部