WIN32_Processor::ProcessorId 对于所有计算机都是唯一的 [英] WIN32_Processor::Is ProcessorId Unique for all computers

查看:53
本文介绍了WIN32_Processor::ProcessorId 对于所有计算机都是唯一的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为许可系统使用一些独特的东西.我决定使用 Win32_Processor Management 类中的 ProcessorID.

I want to use some thing unique for a licensing system. i decided to use ProcessorID from Win32_Processor Management class.

我在两个处理器类型相同的不同系统上试过..

I tried on two different systems with same processor type..

它向我显示了两个系统的相同处理器 ID.我正在使用此代码

It shows me same processorID for both system. i am using this code

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;
}

推荐答案

不,不能保证它是唯一的,因为处理器甚至可能不支持 CPUID 指令,在这种情况下,调用可以'不能保证成功.

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.

此外,您忽略了一台机器可能有多个处理器,因此获取单个处理器的 ID 无济于事.

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,最好的办法是创建一个 id,它是系统上各种组件 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.

硬件的各种值的散列(不仅仅是任何散列,而是具有非常很少冲突的散列)就足够了.您可能想要使用完全嵌入系统的东西,例如处理器、主板信息,而不是容易分离/更改的东西,例如 USB 驱动器/集线器/等.

A hash (and not just any, but one that has very few collisions) of various values of the hardware could suffice. 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.

这篇关于WIN32_Processor::ProcessorId 对于所有计算机都是唯一的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆