找传奇、传世资源到传世资源站!

C# 注册机/授权码 例子源码下载

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

C# 注册机/授权码 例子源码下载 C#语言基础-第1张C# 注册机/授权码 例子源码下载 C#语言基础-第2张C# 注册机/授权码 例子源码下载 C#语言基础-第3张using System;using System.Management;using System.Net.NetworkInformation;using Microsoft.Win32;namespace Common{ public class ComputerInfo { public static string GetComputerInfo() { string info = string.Empty; string cpu = GetCPUInfo(); string baseBoard = GetBaseBoardInfo(); string bios = GetBIOSInfo(); string mac = GetMACInfo(); info = string.Concat(cpu, baseBoard, bios, mac); return info; } private static string GetCPUInfo() { string info = string.Empty; info = GetHardWareInfo("Win32_Processor", "ProcessorId"); return info; } private static string GetBIOSInfo() { string info = string.Empty; info = GetHardWareInfo("Win32_BIOS", "SerialNumber"); return info; } private static string GetBaseBoardInfo() { string info = string.Empty; info = GetHardWareInfo("Win32_BaseBoard", "SerialNumber"); return info; } private static string GetMACInfo() { string info = string.Empty; info = GetHardWareInfo("Win32_BaseBoard", "SerialNumber"); return info; } private static string GetHardWareInfo(string typePath, string key) { try { ManagementClass managementClass = new ManagementClass(typePath); ManagementObjectCollection mn = managementClass.GetInstances(); PropertyDataCollection properties = managementClass.Properties; foreach (PropertyData property in properties) { if (property.Name == key) { foreach (ManagementObject m in mn) { return m.Properties[property.Name].Value.ToString(); } } } } catch (Exception ex) { //这里写异常的处理 } return string.Empty; } private static string GetMacAddressByNetworkInformation() { string key = "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\"; string macAddress = string.Empty; try { NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface adapter in nics) { if (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet && adapter.GetPhysicalAddress().ToString().Length != 0) { string fRegistryKey = key adapter.Id "\\Connection"; RegistryKey rk = Registry.LocalMachine.OpenSubKey(fRegistryKey, false); if (rk != null) { string fPnpInstanceID = rk.GetValue("PnpInstanceID", "").ToString(); int fMediaSubType = Convert.ToInt32(rk.GetValue("MediaSubType", 0)); if (fPnpInstanceID.Length > 3 && fPnpInstanceID.Substring(0, 3) == "PCI") { macAddress = adapter.GetPhysicalAddress().ToString(); for (int i = 1; i < 6; i ) { macAddress = macAddress.Insert(3 * i - 1, ":"); } break; } } } } } catch (Exception ex) { //这里写异常的处理 } return macAddress; } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复