取得磁碟机之Volumn及Serial Number_Access数据库教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:巧用Access逐条输出Excel中的记录
Excel 2000并不支持单条记录的输出,如果想把Excel 2000里的通讯录一条一条打出来,倒也成问题。来来来,且看我是如何让它乖乖就范的! 比起Excel 2000 来说,Access才能算是个数据库,毕竟E

适用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根据数据类型,使用了一个索引来依照合理的顺序分类数据。正确的索引能够提高其性能,而错误的索引则会降低效率。到目前为止,最常见的错误就是设置过多的索引。因为Acc

来源:模板无忧//所属分类:Access数据库教程/更新时间:2008-08-22
相关Access数据库教程