• 有关时间限制使用和软件注册的设计(delphi)


    http://blog.sina.com.cn/s/blog_693cf1cf0100oyus.html

    procedure TForm1.form1create(Sender: TObject);
    var
    re_id:integer;
    registerTemp : TRegistry;
    inputstr,get_id:string;
    dy,clickedok:boolean;
    begin
     dy:=false; //软件是否已到注册期、及是否允许继续使用的标志,当值为FALSE是为允许使用。
     registerTemp := TRegistry.Create; //准备使用注册表
     with registerTemp do
     begin
       RootKey:=HKEY_LOCAL_MACHINE; //存放在此根下
       if OpenKey('SoftwareMicrosoftWindowsCurrentVersionMark',True) then
        // 建一目录,存放标志值
        begin
         if valueexists('gc_id') then begin //用gc_id的值作为标志,首先判断其存在否
           re_id:=readinteger('gc_id');//读出标志值
           if (re_id<>0) and (re_id<>100) then begin //若标志值为0,则说明已注册。
                  //若不为0且值不到100,说明虽未注册,但允许使用的次数尚未达到。
            re_id:=re_id+5; //允许标志的最大值为100,每次加5,则最多只可用20次。
            Writeinteger('gc_id',re_id);//将更新后的标志值写入注册表中。
         end;
         if re_id=100 then dy:=true; //假如值已到100,则应注册。
        end
       else Writeinteger('gc_id',5);//建立标志,并置初始标志值。
      end;
      if dy then begin //若dy值为TRUE,则应提示用户输入注册码,进行注册。
        clickedok:=InputQuery('您使用的是非注册软件,请输入注册码:',' ',inputstr);
        if clickedok then begin
          get_id:=inttostr(27593758*2);//注册码为55187516,当然可加入更杂的算法。
          if get_id=inputstr then begin
            Writeinteger('gc_id',0);//若输入的注册码正确,则将标志值置为0,即已注册。
            CloseKey;
            Free;
           end
          else begin //若输入的注册码错误,应作出提示并拒绝让其继续使用
            application.messagebox('注册码错误!请与作者联系!','警告框',mb_ok);
            CloseKey;
            Free;
            application.terminate; //中止程序运行,拒绝让其继续使用
           end;
          end
        else begin //若用户不输入注册码,也应作出提示并拒绝让其继续使用
          application.messagebox('请与作者联系,使用注册软件!','警告框',mb_ok);
          CloseKey;
          Free;
          application.terminate;
         end;
      end;
     end;
    end;

  • 相关阅读:
    在SharePoint 2010中,如何找回丢失的服务账号(Service Account)密码
    基于Picture Library创建的图片文档库中的上传多个文件功能(upload multiple files)报错怎么解决?
    使用PowerShell找出具体某个站点所使用的模板(Web Template)名称?
    多文档上传(upload multiple documents)功能不能使用怎么办?
    实验环境里新创建成功的web application却在浏览器中返回404错误
    SharePoint 2010中一些必须知道的限制
    Information Management Policy(信息管理策略)的使用范例
    Google云平台对于2014世界杯半决赛的预测,德国阿根廷胜!
    php 字符串分割输出
    php实现验证码(数字、字母、汉字)
  • 原文地址:https://www.cnblogs.com/tc310/p/5200102.html
Copyright © 2020-2023  润新知