- 什么是 PC 唯一 ID?
- 我们如何获得 PC unqiue ID?
- 是硬盘还是主板?
我想将 PC ID 存储在我的窗口程序中。请分享给我。
我想将 PC ID 存储在我的窗口程序中。请分享给我。
这对我有用
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
看这里
试试这个,它会从处理器中提取 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())
Next
我假设你想生成一个机器唯一的 ID。硬盘驱动器可能是最简单的方法,因为其他硬件种类繁多,没有一套检索其序列号的方法。
可能最简单的方法是使用 Windows 为硬盘驱动器生成的数字。
您可以在 HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices 下找到它,键名是 \DosDevices\C:(假设 C: 驱动器是主系统驱动器 - 在极少数情况下并非如此,但随后您可以检查系统驱动器是什么并使用适当的密钥)。
还有另一个与硬盘相关的数字,称为 UUID,您可以找到脚本来获取它。例如: http: //www.windowsnetworking.com/articles_tutorials/Deploying-Windows-7-Part18.html适用于 Windows。或者http://blog.granneman.com/2007/07/26/find-out-a-hard-drives-uuid/对于 Linux。
我还发现了这篇关于检索主板序列号的文章:通过 vc++ 编程获取主板唯一 ID 号
需要 https://www.nuget.org/packages/System.Management/
系统管理 4.7.0
如您所见,有一个“唯一值”加上一些特殊计算。你可以尽可能地做到这一点,但逆向工程最终会暴露这一点。
计算机 ID 的更好(但更慢)版本(需要 System.Management 导入和引用):代码:
Public Shared Function GetComputerID() As Long
Dim objMOS As New ManagementObjectSearcher("Select * From Win32_Processor")
For Each objMO As Management.ManagementObject In objMOS.Get
GetComputerID += objMO("ProcessorID").GetHashCode
Next
GetComputerID += My.Computer.Name.GetHashCode
End Function