Пример #1
0
 private void FormRegister_Load(object sender, EventArgs e)
 {
     softAuthorize              = new SoftAuthorize();                         //实例化
     softAuthorize.ILogNet      = new LogNetSingle("log.txt");                 //日志
     softAuthorize.FileSavePath = Application.StartupPath + @"\Authorize.txt"; // 设置存储激活码的文件,该存储是加密
     softAuthorize.LoadByFile();
 }
Пример #2
0
 /// <summary>
 /// 实例化授权注册窗口
 /// </summary>
 /// <param name="authorize"></param>
 /// <param name="aboutCode">提示关于怎么获取注册码的信息</param>
 /// <param name="encrypt">加密的方法</param>
 public FormAuthorize(SoftAuthorize authorize, string aboutCode, Func <string, string> encrypt)
 {
     InitializeComponent();
     softAuthorize = authorize;
     AboutCode     = aboutCode;
     Encrypt       = encrypt;
 }
Пример #3
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();
            //}
        }