我想把个人电脑ID存储在我的窗口程序中。请和我分享一下。
发布于 2015-04-22 09:15:38
这对我来说很有用
Private Function CpuId() As String
Dim computer As String = "."
Dim wmi As Object = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & _
computer & "\root\cimv2")
Dim processors As Object = wmi.ExecQuery("Select * from " & _
"Win32_Processor")
Dim cpu_ids As String = ""
For Each cpu As Object In processors
cpu_ids = cpu_ids & ", " & cpu.ProcessorId
Next cpu
If cpu_ids.Length > 0 Then cpu_ids = _
cpu_ids.Substring(2)
Return cpu_ids
End Function请参阅这里
发布于 2011-09-26 03:40:49
试试这个,它从处理器上取出ID。
Dim win32MgmtClass as System.Management.ManagementClass
win32MgmtClass = new System.Management.ManagementClass("Win32_Processor")
Dim processors as System.Management.ManagementObjectCollection
processors = win32MgmtClass.GetInstances()
For Each processor As System.Management.ManagementObject In processors
MessageBox.Show(processor("ProcessorID").ToString())
Nexthttps://stackoverflow.com/questions/7550354
复制相似问题