private void button3_Click(object sender, EventArgs e) { // 检测激活码是否正确,没有文件,或激活码错误都算作激活失败 if (!softAuthorize.IsAuthorizeSuccess(AuthorizeEncrypted)) { // 显示注册窗口 using ( FormAuthorize form = new FormAuthorize(softAuthorize, "请联系华天世纪激光科技有限公司获取激活码!", AuthorizeEncrypted)) { if (form.ShowDialog() != DialogResult.OK) { // 授权失败,退出 MessageBox.Show("授权失败!"); } else { MessageBox.Show("授权成功!"); } } } else { MessageBox.Show("授权成功!"); } }
/// <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(); //} }