C# WIN32_Processor::ProcessorId 对于所有计算机都是唯一的
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1101772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WIN32_Processor::Is ProcessorId Unique for all computers
提问by Mohsan
I want to use some thing unique for a licensing system. i decided to use ProcessorID from Win32_Processor Management class.
我想为许可系统使用一些独特的东西。我决定使用 Win32_Processor Management 类中的 ProcessorID。
I tried on two different systems with same processor type..
我在两个具有相同处理器类型的不同系统上尝试过..
It shows me same processorID for both system. i am using this code
它向我显示了两个系统的相同处理器 ID。我正在使用此代码
public static String GetCPUId()
{
String processorID = "";
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
"Select * FROM WIN32_Processor");
ManagementObjectCollection mObject = searcher.Get();
foreach (ManagementObject obj in mObject)
{
processorID = obj["ProcessorId"].ToString();
}
return processorID;
}
采纳答案by casperOne
No, it can't be guaranteed that it will be unique, as the processor might not even support the CPUID instruction, in which case, the call can't be guaranteed to succeed.
不,不能保证它是唯一的,因为处理器甚至可能不支持 CPUID 指令,在这种情况下,不能保证调用成功。
Also, you are neglecting that a machine might have multiple processors in it, so getting the id of a single processor doesn't help.
此外,您忽略了一台机器可能有多个处理器,因此获取单个处理器的 ID 无济于事。
As others have indicated, if you want to get a unique id for the system, your best bet is to create an id which is an amalgam of various component ids on the system.
正如其他人指出的那样,如果您想获得系统的唯一 ID,最好的办法是创建一个 ID,它是系统上各种组件 ID 的混合体。
A hash (and not just any, but one that has veryfew collisions) of various values of the hardware couldsuffice. You'd probably want to use things that are fairly embedded in the system, such as the processor, motherboard info, but not things easily detached/changed, such as USB drives/hubs/etc.
(有,不是任何,但一个散列十分硬件的各种值的一些冲突)可能就足够了。您可能想要使用完全嵌入系统的东西,例如处理器、主板信息,而不是容易分离/更改的东西,例如 USB 驱动器/集线器/等。
回答by Brian R. Bondy
For the unique string you're looking for, we use the MAC address. If the user doesn't have a MAC addresswe simply allow multiple installs. It covers most cases which is all we wanted to accomplish.
对于您要查找的唯一字符串,我们使用 MAC 地址。如果用户没有MAC 地址,我们只允许多次安装。它涵盖了我们想要完成的大多数情况。
回答by Paul Alexander
Most licensing systems rely on multiple hardware components to create a fingerprint. No single component is used as the only unique key. So you might take the following into consideration:
大多数许可系统依赖多个硬件组件来创建指纹。没有单个组件用作唯一的唯一键。所以你可以考虑以下几点:
- MAC Addresses of all network adapters (Can get tricky if they have a docking station or enable/disable their wireless on a laptop)
- CPUID
- Motherboard component part numbers (like the IDE or SCSI controllers)
- Serial number of system drive (NOT Volume ID which is easy to change)
- etc.
- 所有网络适配器的 MAC 地址(如果它们有扩展坞或在笔记本电脑上启用/禁用无线,则可能会变得棘手)
- CPUID
- 主板组件部件号(如 IDE 或 SCSI 控制器)
- 系统驱动器的序列号(不是易于更改的卷 ID)
- 等等。
When combined as a whole you'll get a unique representation of the machine. The danger of course comes when the user changes something on their machine. Do they lose their license? Do they have to contact you?
当作为一个整体组合时,您将获得机器的独特表示。当用户在他们的机器上更改某些内容时,当然会出现危险。他们会失去执照吗?他们需要联系你吗?
Also note that WMI classes often require admin rights to read the kind of information that you're looking for which would be a real hassle for Vista & Windows 7 users.
另请注意,WMI 类通常需要管理员权限才能读取您正在查找的信息类型,这对于 Vista 和 Windows 7 用户来说是一个真正的麻烦。
Doing hardware locking is very difficult to get right. So I'd recommend either 1. don't do it or 2. purchase a commercial library that already does this.
做硬件锁定是非常困难的。所以我建议 1. 不要这样做或 2. 购买已经这样做的商业图书馆。
回答by Trisped
The ProcessorID or CPUID are for identifying the model and feature set of the processor (ARM, x86/x64).
ProcessorID 或 CPUID 用于标识处理器的型号和功能集(ARM、x86/x64)。
The Pentium III supported a Processor Serial Number (PSN). In addition to only being supported on the Pentium III (and Transmeta's Efficeon and Crusoe processors), the feature had to be enabled in BIOS and raised privacy concerns.
Pentium III 支持处理器序列号 (PSN)。 除了仅在 Pentium III(以及 Transmeta 的 Efficeon 和 Crusoe 处理器)上支持之外,该功能还必须在 BIOS 中启用并引起隐私问题。
So no, ProcessorID is not unique for all computers. Additionally, it is very likely to not be unique across computers in your company (since many organizations buy multiple computers of the same model).
所以不,ProcessorID 不是所有计算机都唯一的。此外,它很可能在您公司的计算机中不是唯一的(因为许多组织购买多台相同型号的计算机)。