最安全的办法让处理器ID或一些硬件信息处理器、办法、硬件、安全

2023-09-02 20:46:52 作者:和孤独很熟

我需要得到任何信息来识别一台机器,什么我用到目前为止了以下内容:

I need to get any info to identify a machine and what I was using so far was the following:

    internal static string GetProcessorId()
    {
        try
        {
            StringBuilder sb = new StringBuilder();
            using (System.Management.ManagementClass theClass = new System.Management.ManagementClass("Win32_Processor"))
            {
                using (System.Management.ManagementObjectCollection theCollectionOfResults = theClass.GetInstances())
                {
                    foreach (System.Management.ManagementObject currentResult in theCollectionOfResults)
                    {
                        sb.Append(currentResult["ProcessorID"].ToString());
                    }
                }
            }
            return sb.ToString();
        }
        catch (Exception exception)
        {
            Console.WriteLine(exception.Message);
            return "";
        }
    }

但是,当我在Windows XP上运行此(从虚拟机),我的 currentResult [ProcessorID] 。我不知道这是否是因为我使用的虚拟机,但它可能是因为是XP。无论如何,我不是很信任这个code。是否足够安全?我应该得到一台电脑编号一些其他的方式?这是一个发牌制度,我发展的组成部分。

But when I run this on Windows XP (from a Virtual Machine), my currentResult["ProcessorID"] is null. I'm not sure if it is because I'm using a virtual machine, but it might be because is XP. Anyway, I'm not very trustful of this code. Is it safe enough? Should I get a computer Id some other way? This is all part of a licensing system I'm developing.

推荐答案

对于一个小工具,我写了(Windows窗体.NET 2.0),我需要类似的东西。

For a small tool I wrote (Windows Forms .NET 2.0), I needed something similar.

我写的只是使用的 GetVolumeInformation 的功能。

I wrote a helper class that simply uses some common information like HDD serial number through PInvoke of the GetVolumeInformation function.

这是没有办法真正的安全或防弹的,但不够精确,适合我的需要。

This is by no way really safe or bullet-proof, but accurate enough to fit my needs.

(如果您有兴趣这是工具,如果我允许链接到)

(If you are interested this is the tool, if I'm allowed to link to)