private void CheckLicense() { HashPass.refreshLicInfo(); //if (isLicError == true) // Application.Exit(); string winPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows); string licPath = Path.Combine(winPath, "clc.clc"); if (File.Exists(licPath) && HashPass.isExpired != true) { string licType = HashPass.CheckLicense(); if (licType == "error") { label_WrongPass.Show(); label_WrongPass.Text = "License read error!"; txtBx_Pass.Enabled = false; isLicError = true; //Application.Exit(); } else if (licType == "n") { label_WrongPass.Show(); label_WrongPass.Text = "Invalid License!"; txtBx_Pass.Enabled = false; isLicError = true; //Application.Exit(); } else if (licType == "t" || licType == "p") { isLicError = false; txtBx_Pass.Enabled = true; HashPass.LicType = licType; } } else { txtBx_Pass.Enabled = false; if (HashPass.isExpired == true) { this.TopMost = false; MessageBox.Show("Your license is expired!"); label_WrongPass.Show(); label_WrongPass.Text = "License Expired!"; } Form_License frmLic = new Form_License(); this.TopMost = false; frmLic.ShowDialog(); } }
private void Form_Settings_Activated(object sender, EventArgs e) { string keyName = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"; string valueName = Application.ProductName; using (RegistryKey Key = Registry.CurrentUser.OpenSubKey(keyName)) if (Key != null) { string[] val = Key.GetValueNames(); if (!val.Contains(valueName)) { checkBox_startup.Checked = false; } else { checkBox_startup.Checked = true; } } string[] ports = SerialPort.GetPortNames(); if (ports.Length > 0) { for (int i = 0; i < ports.Length; i++) { comboBox_Ports.Items.Add(ports[i]); } //comboBox_Ports.SelectedIndex = 0; comboBox_Ports.Text = Form1.portName; comboBox_Baudrate.Text = Form1.curr_baudRate; comboBox_DataBits.Text = Form1.DataBits; comboBox_Parity.Text = Form1.Parity; } else { comboBox_Ports.Text = "No Serial Port!"; } HashPass.refreshLicInfo(); lbl_name.Text = HashPass.licenseName; lbl_licType.Text = HashPass.licenseType; if (HashPass.licenseType == "Expired!") { lbl_licType.ForeColor = Color.Red; } else { lbl_licType.ForeColor = Color.Navy; } cmbBx_User.Items.Clear(); if (Form1.isInServiceMode) { cmbBx_User.Items.Add("Service"); cmbBx_User.Text = "Service"; } else { cmbBx_User.Items.Add("Clinical"); cmbBx_User.Text = "Clinical"; } }