适用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),可取得磁碟机的两项资料。 |
|站长邮箱|小黑屋|手机版|Office中国/Access中国
( 粤ICP备10043721号-1 )
GMT+8, 2025-4-3 13:55 , Processed in 0.146395 second(s), 16 queries .
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.