以前写的,供参考
引用定义
Private Declare Function GetVolumeInformation Lib "kernel32.dll" Alias "GetVolumeInformationA" (ByVal _
lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal _
lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long '取得内存磁盘参数调用
函数:
Function GetInfoHard(strDrive As String) As Long
Dim SerialNum As Long, Res As Long, temp1 As String, Temp2 As String
temp1 = String$(255, Chr$(0)): Temp2 = String$(255, Chr$(0))
Res = GetVolumeInformation(strDrive, temp1, Len(temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
GetInfoHard = SerialNum
End Function
调用格式 GetInfoHard("c:\")