Beispiel #1
0
        /// <summary>
        /// 检测软件是否授权
        /// </summary>
        public static void CheckSoftAuthorize()
        {
            SoftAuthorize m_softAuthorize = new SoftAuthorize();

            //方式一
            m_softAuthorize.FileSavePath = Application.StartupPath + @"\Authorize.sys"; //存储激活码文件,存储加密
            m_softAuthorize.LoadByFile();

            // 检测激活码是否正确,没有文件,或激活码错误都算作激活失败
            if (!m_softAuthorize.IsAuthorizeSuccess(AuthorizeEncrypted))
            {
                //显示注册窗口
                using (FormAuthorize form = new FormAuthorize(m_softAuthorize, "请填写注册码!", AuthorizeEncrypted))
                {
                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        //授权失败,退出应用程序
                        Application.Exit();
                    }
                }
            }

            //方式二 :直接进行判断授权码
            //if (!m_softAuthorize.CheckAuthorize("4408B6C4F17EF79B0210F997771C1E5FBA75748F5DD9DD3C59B9E69FCE05DAF5", AuthorizeEncrypted))
            //{
            //    //授权失败!
            //    Application.Exit();
            //}
        }
Beispiel #2
0
        private void Register()
        {
            InitializeComponent();
            softAuthorize = new HslCommunication.BasicFramework.SoftAuthorize();
            softAuthorize.FileSavePath = Environment.CurrentDirectory + @"\Authorize.txt"; // 设置存储激活码的文件,该存储是加密的
            softAuthorize.LoadByFile();

            // 检测激活码是否正确,没有文件,或激活码错误都算作激活失败
            if (!softAuthorize.IsAuthorizeSuccess(AuthorizeEncrypted))
            {
                // 显示注册窗口
                using (HslCommunication.BasicFramework.FormAuthorize form =
                           new HslCommunication.BasicFramework.FormAuthorize(
                               softAuthorize,
                               "请联系管理员获取激活码",
                               AuthorizeEncrypted))
                {
                    if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    {
                        // 授权失败,退出
                        Close();
                        App.Current.Shutdown();
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 检测软件是否授权
        /// </summary>
        private void CheckSoftAuthorize()
        {
            m_softAuthorize = new SoftAuthorize();

            //方式一
            m_softAuthorize.FileSavePath = Application.StartupPath + @"\Authorize.sys"; //存储激活码文件,存储加密
            m_softAuthorize.LoadByFile();

            // 检测激活码是否正确,没有文件,或激活码错误都算作激活失败
            if (!m_softAuthorize.IsAuthorizeSuccess(AuthorizeEncrypted))
            {
                File.SetAttributes(m_softAuthorize.FileSavePath, FileAttributes.ReadOnly);

                using (FormAuthorize form = new FormAuthorize(m_softAuthorize, "请联系华天世纪激光科技公司获取注册码!", AuthorizeEncrypted))
                {
                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        Close();
                    }
                }
            }

            //方式二 :直接进行判断授权码
            //if (!m_softAuthorize.CheckAuthorize("CC2A56387E05A1953ABCE666892B916617CA21808A35ABE1B7592DF20DB44CF6", AuthorizeEncrypted))
            //{
            //    Close();
            //}
        }
Beispiel #4
0
 private static SoftAuthorize softAuthorize = null;//授权
 /// <summary>
 /// 授权验证
 /// </summary>
 /// <returns></returns>
 public static bool Authorize(string prompt)
 {
     //授权
     if (string.IsNullOrEmpty(prompt))
     {
         prompt = "Please contact the supplier for registration code";
     }
     softAuthorize = new SoftAuthorize();
     softAuthorize.FileSavePath = Application.StartupPath + @"\Authorize.txt"; // 设置存储激活码的文件,该存储是加密的
     softAuthorize.LoadByFile();
     // 检测激活码是否正确,没有文件,或激活码错误都算作激活失败
     if (!softAuthorize.IsAuthorizeSuccess(AuthorizeEncrypted))
     {
         // 显示注册窗口
         using (FormAuthorize form =
                    new FormAuthorize(
                        softAuthorize,
                        prompt,
                        AuthorizeEncrypted))
         {
             if (form.ShowDialog() != DialogResult.OK)
             {
                 // 授权失败,退出
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
     }
     else
     {
         return(true);
     }
 }