예제 #1
0
        private bool CheckIsRegister(RegModel reg)
        {
            /*
             * 检测方式:
             * 机器码+type+秘钥
             *
             */
            bool flag = false;
            if (reg._type.Equals("Person"))
            {
                string code = reg._code;
                string user = reg._IncName;
                string key = reg._key;

                if (Lincense.getInstance().GetCode2(code).Contains(key))
                {
                    flag = true;
                    return flag;
                }

            }
            else//这个是 批量注册码
            {

            }

            return flag;
        }
예제 #2
0
        private void ShowUnRegisteredInfo(RegModel reg)
        {
            lab_status.Text = "未注册";

            gb_registersuccess.Visible = false;
            gb_noregister.Visible = true;

            gb_noregister.Text = "未注册";
            lab_machinecode.Text = reg._code;
            lab_installtime.Text = reg._installTime;
            txt_requeststr.Text = reg._code;
        }
예제 #3
0
        //[RegistryPermissionAttribute(SecurityAction.PermitOnly, Write = @"HKEY_CURRENT_USER\SOFTWARE\DBFConvert")]
        //[RegistryPermissionAttribute(SecurityAction.PermitOnly, Write = @"HKEY_LOCAL_MACHINE\SOFTWARE\DBFConvert")]
        private RegModel GetRegisterInfo()
        {
            RegModel regModel = new RegModel();
            Microsoft.Win32.RegistryKey localRegKey = Microsoft.Win32.Registry.LocalMachine;
            Microsoft.Win32.RegistryKey userRegKey = Microsoft.Win32.Registry.CurrentUser;
            try
            {
                regModel._installTime = localRegKey.OpenSubKey(regPath).GetValue("InstallTime").ToString();

                string[] subkeys1 = (localRegKey.OpenSubKey(regPath).GetSubKeyNames());
                string[] subkeys2 = (userRegKey.OpenSubKey(regPath).GetSubKeyNames());
                if (subkeys1.Length == 1 && subkeys2.Length == 1)
                {
                    if (subkeys1[0].Equals(subkeys2[0]))
                    {
                        regModel._code = subkeys1[0];
                        Microsoft.Win32.RegistryKey userRegSetCodeKey = userRegKey.OpenSubKey(regPath).OpenSubKey(subkeys1[0]);
                        string[] subkeys_codes = userRegSetCodeKey.GetValueNames();

                        foreach (string item in subkeys_codes)
                        {
                            if (item.Equals("ActivityTime"))
                            {
                                regModel._activeTime = userRegSetCodeKey.GetValue("ActivityTime").ToString();
                            }
                            else if (item.Equals("Type")) //Person,Inc
                            {
                                regModel._type = userRegSetCodeKey.GetValue("Type").ToString();
                            }
                            else if (item.Equals(Lincense.GetMd5("Person")))
                            {
                                regModel._IncName = "Person";

                                regModel._key = userRegSetCodeKey.GetValue(item).ToString();
                            }
                            else
                            {
                                regModel._IncName = "Person";
                                regModel._key = userRegSetCodeKey.GetValue(item).ToString();
                            }
                        }
                        return regModel;
                    }
                }
                //////把机器码加进去
                ClearReg(localRegKey, userRegKey);
                string jiqicode = Lincense.getInstance().CreateCode();
                regModel._code = jiqicode;
                localRegKey.OpenSubKey(regPath, true).CreateSubKey(jiqicode);
                userRegKey.OpenSubKey(regPath, true).CreateSubKey(jiqicode);
            }
            catch (Exception e)
            {

                throw;
            }
            finally
            {
                localRegKey.Close();
                userRegKey.Close();
            }

               return regModel;
        }
예제 #4
0
        private void ShowRegisteredInfo(RegModel reg)
        {
            lab_status.Text = "已注册";

            gb_noregister.Visible = false;
            gb_registersuccess.Visible = true;
            gb_registersuccess.Location = new Point(28,62);

            gb_registersuccess.Text = "已注册";
            lab_machinecode2.Text = reg._code;
            lab_installtime2.Text = reg._installTime;
            lab_registertime.Text = reg._activeTime;
        }
예제 #5
0
파일: Common.cs 프로젝트: NEU108/DBFConvert
        //[RegistryPermissionAttribute(SecurityAction.PermitOnly, Read = @"HKEY_CURRENT_USER\SOFTWARE\DBFConvert")]
        //[RegistryPermissionAttribute(SecurityAction.PermitOnly, Read = @"HKEY_LOCAL_MACHINE\SOFTWARE\DBFConvert")]
        private static RegModel CheckIsRegister1()
        {
            RegModel regModel = new RegModel();

            Microsoft.Win32.RegistryKey localRegKey = Microsoft.Win32.Registry.LocalMachine;
            Microsoft.Win32.RegistryKey userRegKey = Microsoft.Win32.Registry.CurrentUser;
            try
            {
                string regPath = "software\\DBFConvert\\DBFConvertSet\\";

                    //安装时间问题
                    if (localRegKey.OpenSubKey(regPath).GetValue("InstallTime").ToString().Trim() == "")
                    {
                        localRegKey.OpenSubKey(regPath, true).SetValue("InstallTime", DateTime.Now.ToString("yyyy-MM-dd HH:MM:ss"));
                        userRegKey.OpenSubKey(regPath, true).SetValue("InstallTime", DateTime.Now.ToString("yyyy-MM-dd HH:MM:ss"));
                    }
                    regModel._installTime = localRegKey.OpenSubKey(regPath).GetValue("InstallTime").ToString();

                string[] subkeys1 = (localRegKey.OpenSubKey(regPath).GetSubKeyNames());

                if (subkeys1.Length == 1)
                {
                        regModel._code = subkeys1[0];
                        Microsoft.Win32.RegistryKey userRegSetCodeKey = localRegKey.OpenSubKey(regPath).OpenSubKey(subkeys1[0]);
                        string[] subkeys_codes = userRegSetCodeKey.GetValueNames();

                        foreach (string item in subkeys_codes)
                        {
                            if (item.Equals("ActivityTime"))
                            {
                                regModel._activeTime = userRegSetCodeKey.GetValue("ActivityTime").ToString();
                            }
                            else if (item.Equals("Type")) //Person,Inc
                            {
                                regModel._type = userRegSetCodeKey.GetValue("Type").ToString();
                            }
                            else if (item.Equals(Lincense.GetMd5("Person")))
                            {
                                regModel._IncName = "Person";

                                regModel._key = userRegSetCodeKey.GetValue(item).ToString();
                            }
                            else
                            {
                                regModel._IncName = "Person";
                                regModel._key = userRegSetCodeKey.GetValue(item).ToString();
                            }
                      }
                }
                return regModel;
            }
            catch (Exception e)
            {
                //throw;
                //edit by sjl
                //throw e;
            }
            finally
            {
                localRegKey.Close();
            }
            return null;
        }