'取得“逻辑”盘序列号(非唯一)
Function GetDiskVolume(Optional ByVal strDiskName = "C") As String
Dim TempStr1 As String * 256, TempStr2 As String * 256
Dim TempLon1 As Long, TempLon2 As Long, GetVal As Long
Dim tmpVol As String
Call GetVolumeInformation(strDiskName & ":\", TempStr1, 256, GetVal, TempLon1, TempLon2, TempStr2, 256)
If GetVal = 0 Then
tmpVol = ""
Else
tmpVol = Hex(GetVal)
tmpVol = String(8 - Len(tmpVol), "0") & tmpVol
tmpVol = Left(tmpVol, 4) & "-" & Right(tmpVol, 4)
End If
GetDiskVolume = tmpVol
End Function
'取得硬盘“物理”信息:型号/序列号(唯一)
Function GetHardDiskInfo(Optional ByVal numDisk As eumDiskNo = hdPrimaryMaster, Optional ByVal numType As eumInfoType = hdOnlySN) As String
If GetDiskInfo(numDisk) = 1 Then
Dim pSerialNumber As String, pModelNumber As String
pSerialNumber = StrConv(m_DiskInfo.sSerialNumber, vbUnicode)
pModelNumber = StrConv(m_DiskInfo.sModelNumber, vbUnicode)
Select Case numType
Case hdOnlyModel '仅型号
GetHardDiskInfo = Trim(pModelNumber)
Case hdOnlySN '仅序列号
GetHardDiskInfo = Trim(pSerialNumber)
Case Else '型号和序列号
GetHardDiskInfo = Trim(pModelNumber) & "," & Trim(pSerialNumber)
End Select
End If