国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > 数据库 > access > 取得磁碟机之Volumn及Serial Number

取得磁碟机之Volumn及Serial Number

来源:程序员人生   发布时间:2013-10-31 03:27:38 阅读次数:3528次

   适用ACCESS

 这两项磁碟机资料须使用API函数方可取得代码如下
Private Declare Function GetVolumeInformation Lib "kernel" 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) < Then
        X = Left(X ) & ":"
    Else
        X = Left(X )
    End If
    Dim nRet As Long VolName As String VolSN As Long MaxCompLen As Long
    Dim VolFlags As Long VolFileSys As String
    VolName = Space$()
    VolFileSys = Space$()
    nRet = GetVolumeInformation(X VolName Len(VolName) _
            VolSN MaxCompLen VolFlags _
            VolFileSys Len(VolFileSys))
    If nRet = Then
        GetVolumn = VolName
    Else
        GetVolumn = ""
    End If
End Function

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

前面的Declare陈述式宣告一个API函数(GetVolumeInformation)可取得磁碟机的两项资料    

生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生