mac地址怎么能改变?

时间:2013-06-11 09:23:50

标签: c#

我的软件有一个相当粗略的许可证密钥,它找到一台机器的所有mac地址并加密它们,然后将它们与注册表中保存的加密值进行比较。如果注册表中的值与我刚找到的任何值匹配,则软件将加载。我希望我总能得到相同的MAC地址值,但对于一些机器,这不是真的。任何人都可以解释为什么他们的MAC地址没有修复,或者如何解决这个问题?

由于

        //// GET MAC ADDRESS
        String sMacAddress = String.Empty;
        ManagementScope theScope = new ManagementScope("\\\\" +Environment.MachineName + "\\root\\cimv2");
        DGCSLogger.log.Trace("Management scope");

        StringBuilder theQueryBuilder = new StringBuilder();

        theQueryBuilder.Append("SELECT MACAddress FROM Win32_NetworkAdapter");
        ObjectQuery theQuery = new ObjectQuery(theQueryBuilder.ToString());

        DGCSLogger.log.Trace("Creating searcher");

        ManagementObjectSearcher theSearcher = new ManagementObjectSearcher(theScope, theQuery);
        DGCSLogger.log.Trace("Creating collection");
        ManagementObjectCollection theCollectionOfResults = theSearcher.Get();

        DGCSLogger.log.Trace("Got management objects");

        //// GET VALUE FROM REGISTRY
        String sSavedScrambled = RegistryHelper.GetCurrentUserValue(@"Software\VB and VBA Program Settings\FMPos\settings", "LicenceKey");
        String sSavedLicenceKey = String.Empty;
        if (sSavedScrambled != null)
            sSavedLicenceKey = DGCS.Common.Password.UnScramblePassword(sSavedScrambled);

        String sMacNoLicenceKey = String.Empty;
        String sMacNo  = String.Empty;


         ///// COMPARE VALUES WITH REGISTRY VALUE
        foreach (ManagementObject theCurrentObject in theCollectionOfResults)
        {
            DGCSLogger.log.Trace("foreach object");

            if (theCurrentObject["MACAddress"] != null)
            {
                DGCSLogger.log.Trace("foreach object: " + theCurrentObject["MACAddress"].ToString().Substring(0, 5));

                String macAdd =  theCurrentObject["MACAddress"].ToString();

                sMacNo = DGCS.Common.Password.ScrambleMacNumber(theCurrentObject["MACAddress"].ToString());
                sMacNoLicenceKey = DGCS.Common.Password.CreateMacNoPassword(sMacNo);

                DGCSLogger.log.Trace(": " + theCurrentObject["MACAddress"].ToString().Substring(0, 5));

                if (sMacNoLicenceKey.Trim() == sSavedLicenceKey.Trim())
                    lkCheck.HasLicenceKey = true;
            }
        }

1 个答案:

答案 0 :(得分:0)

各种可能的原因:

  1. 他们可能更换了网卡
  2. WMI枚举可能以不同的顺序返回它们(我没有看到任何排序)
  3. 他们实际上可能会更改MAC地址(是的,this is possible
  4. ...
  5. 这就是为什么MAC地址实际上不是创建许可证密钥的好参考。