我要投稿
  • 您当前的位置:365bet官方 -> 技术教程 -> 数据库教程 -> Access教程 -> 教程内容
  • [ 收藏本页教程 ]
  • 取得磁碟机之Volumn及Serial Numberaccess教程

    教程作者:佚名    教程来源:不详   教程栏目:Access教程    收藏本页
    适用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),可取得磁碟机的两项资料。
    我要投稿   -   广告合作   -   关于本站   -   友情连接   -   网站地图   -   联系我们   -   版权声明   -   设为首页   -   加入收藏   -   网站留言
    Copyright © 2009 - 20012 www.www.ct131.com All Rights Reserved.365bet官方 版权所有