private void btnComputer_Click(object sender, EventArgs e) { string computerName = HardwareInfoHelper.GetComputerName(); string userName = HardwareInfoHelper.GetUserName(); string systemType = HardwareInfoHelper.GetSystemType(); string cpuid = HardwareInfoHelper.GetCPUId(); string cpuName = HardwareInfoHelper.GetCPUName(); int cpuUsage = HardwareInfoHelper.GetCpuUsage(); string diskId = HardwareInfoHelper.GetDiskID(); string ip = HardwareInfoHelper.GetIPAddress(); string macAddress = HardwareInfoHelper.GetMacAddress(); string memery = HardwareInfoHelper.GetTotalPhysicalMemory(); StringBuilder sb = new StringBuilder(); sb.AppendFormat("ComputerName:\t {0} \r\n", computerName); sb.AppendFormat("UserName:\t {0} \r\n", userName); sb.AppendFormat("SystemType:\t {0} \r\n", systemType); sb.AppendFormat("CPU ID:\t {0} \r\n", cpuid); sb.AppendFormat("CPU Name:\t {0} \r\n", cpuName); sb.AppendFormat("CPU Usage:\t {0} \r\n", cpuUsage); sb.AppendFormat("Disk Id:\t {0} \r\n", diskId); sb.AppendFormat("IP:\t {0} \r\n", ip); sb.AppendFormat("MacAddress:\t {0} \r\n", macAddress); sb.AppendFormat("TotalPhysicalMemory:\t {0} \r\n", memery); MessageDxUtil.ShowTips(sb.ToString()); string identity = FingerprintHelper.Value(); MessageDxUtil.ShowTips(identity); }
/// <summary> /// 返回注册码信息 (用公钥生成) /// </summary> /// <returns></returns> public static string GetRegistrationCode(string userName, string Company) { string machineCode = HardwareInfoHelper.GetCPUId(); string expireDate = Convert.ToDateTime(Data.getSysDate()).AddYears(1).ToString("yyyy-MM-dd"); string publicKey = Const.publicKey; return(RSASecurityHelper.RSAEncrypt(publicKey, machineCode + Const.VerticalLine + expireDate + Const.VerticalLine + Company + Const.VerticalLine + userName)); }
public string GetHardNumber() { return(HardwareInfoHelper.GetCPUId()); }
/// <summary> /// 调用非对称加密方式对序列号进行验证 /// </summary> /// <param name="serialNumber">正确的序列号</param> /// <returns>如果成功返回True,否则为False</returns> public bool Register(String serialNumber) { string hardNumber = HardwareInfoHelper.GetCPUId(); return(RSASecurityHelper.Validate(hardNumber, serialNumber)); }
/// <summary> /// 验证注册码信息(机器码|有效日期|注册公司|注册用户) /// </summary> /// <param name="encryptedString"> 注册码信息 </param> /// <returns>返回0 表示正确,-1表示注册码错误,-2表示机器码错误, -3表示注册已过期, -4表示其他内部错误, -5 注册人员信息错误,-6注册公司错误</returns> public static Int32 CheckRegistrationCode(string encryptedString, string struserName, string strcompany) { string originalString = null; try { originalString = RSASecurityHelper.RSADecrypt(Const.privateKey, encryptedString); } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(RSASecurityHelper)); return(-1); } string[] d2 = originalString.Split('|'); if (d2.Length != 4) { return(-4); } string machineCode = d2[0]; string expireDate = d2[1]; string companyName = d2[2]; string userName = d2[3]; if (!string.Equals(machineCode, HardwareInfoHelper.GetCPUId(), StringComparison.OrdinalIgnoreCase)) { return(-2); } DateTime nowdt = Convert.ToDateTime(Data.getSysDate()); DateTime expiredt = Convert.ToDateTime(expireDate); if (nowdt > expiredt) { return(-3); } AppConfig config = Cache.Instance["AppConfig"] as AppConfig; if (config == null) { config = new AppConfig(); Cache.Instance["AppConfig"] = config; } string LicensePath = config.AppConfigGet("LicensePath"); if (!string.Equals(struserName, userName, StringComparison.OrdinalIgnoreCase)) { return(-5); } if (!string.Equals(strcompany, companyName, StringComparison.OrdinalIgnoreCase)) { return(-6); } RegistryKey reg; string regkey = UIConstants.SoftwareRegistryKey; reg = Registry.CurrentUser.OpenSubKey(regkey, true); if (null == reg) { reg = Registry.CurrentUser.CreateSubKey(regkey); } if (null != reg) { reg.SetValue("productName", UIConstants.SoftwareProductName); reg.SetValue("version", UIConstants.SoftwareVersion); reg.SetValue("SysDate", expireDate); reg.SetValue("UserName", userName); reg.SetValue("Company", companyName); reg.SetValue("regCode", encryptedString); } // 写入lic 文件 FileUtil.WriteText(LicensePath, encryptedString + Const.VerticalLine + userName + Const.VerticalLine + companyName, Encoding.Default); return(0); }
private string GetHardNumber() { return(HardwareInfoHelper.GetCPUId() + this.GetHexString(HardwareInfoHelper.GetCPUName())); }
/// <summary> /// 获取系统CPU序列号 /// </summary> /// <returns></returns> public string GetCPUSerialID() { return(HardwareInfoHelper.GetCPUId()); }
/// <summary> /// 初始化数据 /// </summary> private void Init_View() { txtMachineCode.Text = HardwareInfoHelper.GetCPUId(); txtExpiredDate.Text = DateTimeHelper.GetServerDateTime2().AddYears(1).ToString("yyyyMMdd"); }
private void btnGetMachineCode_Click(object sender, EventArgs e) { txtMachineCode.Text = HardwareInfoHelper.GetCPUId(); }
private string GetMachineCode() { return(HardwareInfoHelper.GetCPUId()); }
private void RegDlg_Load(object sender, EventArgs e) { txtMachineCode.Text = HardwareInfoHelper.GetCPUId(); }