论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Access数据库教程
Tag:2000,2003,2007,查询,sql,,教程,安全,转换,排序,复制,删除,修改,视频教程

取得磁碟机之Volumn及Serial Number

文章类别:Access数据库 | 发表日期:2008-10-5 18:45:08

适用ACCESS97、2000

 这两项磁碟机资料须使用API函数方可取得,代码如下:
Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long

Function GetVolumn(X As String) As String
    If Len(X) < 3 Then
        X = Left(X, 1) & ":\"
    Else
        X = Left(X, 3)
    End If
    Dim nRet As Long, VolName As String, VolSN As Long, MaxCompLen As Long
    Dim VolFlags As Long, VolFileSys As String
    VolName = Space$(256)
    VolFileSys = Space$(256)
    nRet = GetVolumeInformation(X, VolName, Len(VolName), _
            VolSN, MaxCompLen, VolFlags, _
            VolFileSys, Len(VolFileSys))
    If nRet = 1 Then
        GetVolumn = VolName
    Else
        GetVolumn = ""
    End If
End Function

Function GetNumber(X As String) As String
    If Len(X) < 3 Then
        X = Left(X, 1) & ":\"
    Else
        X = Left(X, 3)
    End If
    Dim nRet As Long, VolName As String, VolSN As Long, MaxCompLen As Long
    Dim VolFlags As Long, VolFileSys As String
    VolName = Space$(256)
    VolFileSys = Space$(256)
    nRet = GetVolumeInformation(X, VolName, Len(VolName), _
            VolSN, MaxCompLen, VolFlags, _
            VolFileSys, Len(VolFileSys))
    If nRet = 1 Then
        GetNumber = VolSN
    Else
        GetVolumn = ""
    End If
End Function

前面的Declare陈述式宣告一个API函数(GetVolumeInformation),可取得磁碟机的两项资料。
视频教程列表
文章教程搜索
 
Access数据库推荐教程
Access数据库热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058