Created
March 4, 2015 15:38
-
-
Save cwschroeder/9a3c4943d03baf389313 to your computer and use it in GitHub Desktop.
Generate machine key for license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string GetSystemInfo(string SoftwareName) | |
{ | |
if (UseProcessorID == true) | |
SoftwareName += RunQuery("Processor", "ProcessorId"); | |
if (UseBaseBoardProduct == true) | |
SoftwareName += RunQuery("BaseBoard", "Product"); | |
if (UseBaseBoardManufacturer == true) | |
SoftwareName += RunQuery("BaseBoard", "Manufacturer"); | |
// See more in source code | |
SoftwareName = RemoveUseLess(SoftwareName); | |
if (SoftwareName.Length < 25) | |
return GetSystemInfo(SoftwareName); | |
return SoftwareName.Substring(0, 25).ToUpper(); | |
} | |
private static string RunQuery(string TableName, string MethodName) | |
{ | |
ManagementObjectSearcher MOS = | |
new ManagementObjectSearcher("Select * from Win32_" + TableName); | |
foreach (ManagementObject MO in MOS.Get()) | |
{ | |
try | |
{ | |
return MO[MethodName].ToString(); | |
} | |
catch (Exception e) | |
{ | |
System.Windows.Forms.MessageBox.Show(e.Message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment