最安全的办法让处理器ID或一些硬件信息 [英] Safest way to get processor ID or some hardware info

查看:132
本文介绍了最安全的办法让处理器ID或一些硬件信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 <像硬盘序列号的一些公共信息通过PInvoke的一个辅助类 / code>的功能。

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)

这篇关于最安全的办法让处理器ID或一些硬件信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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