Exemple #1
0
        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 button2_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             //if (MessageBox.Show("Application will close after importing the license\nClick OK to continue", "Application will close!", MessageBoxButtons.OK, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK)
             //{
             string fileName = openFileDialog1.FileName;
             string name     = openFileDialog1.SafeFileNames[0].Remove(openFileDialog1.SafeFileNames[0].Length - 4, 4);
             HashPass.WriteToReg(name);
             string winPath     = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
             string newFileName = Path.Combine(winPath, "clc.clc");
             if (File.Exists(newFileName))
             {
                 File.Delete(newFileName);
             }
             File.Move(fileName, newFileName);
             if (HashPass.LicType == "p")
             {
                 foreach (Process p in System.Diagnostics.Process.GetProcessesByName("ProcessInfo"))
                 {
                     try
                     {
                         p.Kill();
                         p.WaitForExit();     // possibly with a timeout
                     }
                     catch (Win32Exception winException)
                     {
                         // process was terminating or can't be terminated - deal with it
                     }
                     catch (InvalidOperationException invalidException)
                     {
                         // process has already exited - might be able to let this one go
                     }
                 }
             }
             HashPass.CheckLicense();
             MessageBox.Show("License imported!");
             this.Close();
         }
         //}
         catch
         {
             MessageBox.Show("License import error!");
         }
     }
 }