'获取网上MAC地址
Public Function NicMAC() As String
Dim Nics As Object, oIP As Object
Set Nics = GetObject("Winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
For Each oIP In Nics
If oIP.IPEnabled = True Then
NicMAC = NicMAC & IIf(NicMAC <> "", ";", "") & oIP.MacAddress
Exit For
End If
Next
End Function
'获取硬盘型号
Public Function HDModel() As String
Dim hds As Object, hd As Object
Set hds = GetObject("Winmgmts:").InstancesOf("Win32_DiskDrive")
For Each hd In hds
HDModel = HDModel & IIf(HDModel <> "", ";", "") & hd.Model
Next
End Function
'获取IP地址
Public Function IP() As String
Dim OpSysSet, OpSys, oIP
Set OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate}//localhost"). _
ExecQuery("Select index, IPAddress FROM Win32_NetworkAdapterConfiguration")
For Each OpSys In OpSysSet
If TypeName(OpSys.IPAddress) <> "Null" Then
For Each oIP In OpSys.IPAddress
IP = IP & IIf(IP <> "", ";", "") & oIP
Next
End If
Next
End Function