我的软件有一个相当粗略的许可证密钥,它找到一台机器的所有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;
}
}
答案 0 :(得分:0)
各种可能的原因:
这就是为什么MAC地址实际上不是创建许可证密钥的好参考。