如何获取系统的唯一标识符
我需要系统的唯一标识符。我使用了 processid,但它也不是对所有 PC 都是唯一的。这样我就得到了CPU的序列号。
我正在使用 WMI 来获取序列号。 // Win32_CPU
var search = new ManagementObjectSearcher( "SELECT * FROM Win32_baseboard" );
var mobos = search.Get();
foreach (var m in mobos)
{
var serial = m["SerialNumber"]; // ProcessorID if you use Win32_CPU
}
但它返回“由 OEM 填写”
为什么它不返回准确的序列号。
请让我知道如何解决这个问题。
I need Unique Identifier of the system. I used processid but it also not unique for all PCs. So I get serial number of CPU.
I am using WMI to get serial number.
// Win32_CPU
var search = new ManagementObjectSearcher( "SELECT * FROM Win32_baseboard" );
var mobos = search.Get();
foreach (var m in mobos)
{
var serial = m["SerialNumber"]; // ProcessorID if you use Win32_CPU
}
But It returns "To be filled by O.E.M."
Why It does not returns exact serial number.
Please Let me know How can I Fix this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我之前需要解决同样的问题。
完成 MAC 地址的事情后,结果非常糟糕,因为我们很快就在 10k 用户身上发现了多个重复项。直到产品失效的那一天我们都遇到了问题。
另一个项目需要类似的解决方案,我们尝试了 C:\ 驱动器的 NTFS Id。我们抛弃了这个想法,然后考虑了 Win32 机器 ID,当然也被抛弃了。
最后我们决定如下:我们创建一个 Guid,使用 RSA 机器密钥对其进行加密,并将其粘贴到注册表中。
我真的相信这是实现独特性的最佳选择,即使您还需要合并一些硬件信息。所以这就像我们用来存储 & 的代码一样。拿来:
I've needed to solve the same issue before.
Done the MAC address thing, that broke horribly as we quickly found several duplicates on just 10k users. We had problems to the day that product died.
Another project needed a similar solution and we tried the NTFS Id for C:\ drive. We threw out that idea and then considered the Win32 machine id, that of course also got thrown out.
Finally we settled onto the following: We created a Guid, encrypted it with the RSA machine key, and stuck it in the Registry.
I really believe that is your best bet for uniqueness even if you then need to incorporate some hardware information as well. So here is something like the code we used to store & fetch:
组装计算机的 OEM 从未输入序列号。
要修复此问题,您可以构建自己的计算机并正确输入序列号。
The OEM that assembled the computer never put in a serial number.
To fix it, you can build your own computer and put in the serial number correctly.
您尝试过
Win32_BIOS
吗?Did you try at
Win32_BIOS
?“我需要系统的唯一标识符。”
常见的方法是使用网卡的 MAC。它可以改变,但对于大多数用途来说已经足够了。
您还可以尝试 Win32_Processor、Win32_Bios 或组合。我的意思是连接来自系统的多个组件的标识符,为系统生成唯一的标识符,因此,如果组件标识符之一不唯一,那并不重要。这当然有一个问题,如果组件更改,唯一标识符也会更改。
"I need Unique Identifier of the system."
A common approach is to use the MAC of a network card. It can be altered but for most purposes its good enough.
You could also try Win32_Processor, Win32_Bios or combination. By which I mean concat identifiers from several components of the system to generate a unique identifier for the system so it doesnt matter if for instance one of the component identifier isn't unique. This of course has the problem that if a component changes the unique identifier changes.