Function GetTrait(P)
Dim WMI,Obj
Select Case P
Case "BIOS"
Set WMI =GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_BIOS")
For Each Obj in WMI
GetTrait = Obj.Name
Exit For
Next
Case "磁盘序列号"
Set WMI =GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_PhysicalMedia")
For Each Obj in WMI
GetTrait = Obj.SerialNumber
Exit For
Next
Case "CPUID"
Set WMI =GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Processor")
For Each Obj in WMI
GetTrait = Obj.ProcessorId
Exit For
Next
Case "声卡"
Set WMI =GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_SoundDevice")
For Each Obj in WMI
GetTrait = Obj.Caption
Exit For
Next
Case "显卡"
Set WMI =GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_VideoController")
For Each Obj in WMI
GetTrait = Obj.Caption
Exit For
Next
Case "MAC"
Set WMI =GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_NetworkAdapterConfiguration")
For Each Obj in WMI
If Obj.IPEnabled=True Then
GetTrait = Obj.MacAddress
Exit For
End If
Next
End Select
End Function