现在的位置: 首页 > 综合 > 正文

怎样把本软件是否注册的标志加在程序里?(注:不想加在数据库里)

2012年09月09日 ⁄ 综合 ⁄ 共 3422字 ⁄ 字号 评论关闭
怎样把本软件是否注册的标志加在程序里?(注:不想加在数据库里) Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiDB/html/delphi_20061220125350203.html
本人公司做了一套软件,  
  并且需要注册才可以使用,  
  但是注册成功后不想把注册是否成功的标志保存在数据库、ini文件里,  
  想用更好的方法来做,  
  不知道各位有什么好办法?  
  多谢了,

把注册码放入注册表中,每次去比对。

有没有相关的源码,  
  没做过这些东西,  
  多指教,

没人保存注册是否成功的标志的  
  每次RUN都验证的

关注~帮顶.

三楼讲的对.  
   
  做法:   用户把本机硬件序列号提交给你,你经过运算得出注册码,交给用户注册使用.  
              而这个注册码具体放在哪里是无所谓的,哪怕就用一个TXT放在程序目录下也行,因为别的机器上此码无用.  
              程序每一次运行,都比对注册码与实际的注册码(亦是收集硬件序列号进行运算)是否一致.

多谢各位,  
  还有方法吗,  
  俺想今天揭帖,  
 

给你一个,不过是检测注册表中的值进行判断是否已经注册:  
  当然这程序中的注册码是随便写的...  
  procedure   TE_Mainf.FormCreate(Sender:   TObject);  
  var   re_id:   integer;  
      registerTemp:   TRegistry;  
      inputstr,get_id:   string;  
      dy,   clickedok:   boolean;  
      i:   double;  
  label   Y,   N;  
  begin  
      dy   :=   false;//软件是否已到注册期、及是否允许继续使用的标志,当值为FALSE是为允许使用  
      registerTemp   :=   TRegistry.Create;                 //准备使用注册表  
      with   registerTemp   do  
      begin  
          RootKey   :=   HKEY_LOCAL_MACHINE;                 //存放在此根下  
          if   OpenKey('Software\Microsoft\Windows\CurrentVersion\Mark',   True)   then   //   建一目录,存放标志值。当然也可以存放在已存在的目录下。  
          begin  
              if   valueexists('gc_id')   then                     //用gc_id的值作为标志,首先判断其存在否  
              begin  
                  re_id   :=   readinteger('gc_id');                       //读出标志值  
                  if   (re_id   <>   0)   and   (re_id   <>   100)   then     //若标志值为0,则说明已注册     ,若不为0且值不到100,说明虽未注册,但允许使用的次数尚未达到。  
                  begin  
                      re_id   :=   re_id   +   5;         //允许标志的最大值为100,每次加5,则最多只可用20次  
                      writeinteger('gc_id',   re_id);                     //将更新后的标志值写入注册表中  
                      i   :=   (100   -   re_id)   /   5;  
                      if   application.MessageBox(PAnsiChar('您使用的软件没有注册,还有   '   +   floattostr(i)   +   '   次使用次数,现在要注册吗?'),   '提示信息',   mb_yesno   +   mb_iconwarning)   =   idyes   then  
                      begin  
                          if   i   =   0   then  
                              application.Terminate  
                          else  
                              goto   y;  
                      end;  
                  end;  
                  if   re_id   =   0   then   goto   N;  
                  if   re_id   =   100   then   dy   :=   true;                     //若标志值已达到100,则应当注册  
              end  
              else  
                  Writeinteger('gc_id',   5);                                 //建立标志,并置初始标志值  
              re_id   :=   readinteger('gc_id');  
              i   :=   (100   -   re_id)   /   5;  
              if   Application.MessageBox(PAnsiChar('您使用的软件没有注册,还有   '   +   floattostr(i)   +   '   次使用次数,现在要注册吗?'),   '提示信息',   mb_yesno   +   mb_iconwarning)   =   idyes   then  
              begin  
                  if   i   =   0   then  
                      application.Terminate  
                  else  
                      goto   Y;  
              end;  
          end;  
          if   dy   then  
              Y:   begin                                 //若dy值为TRUE,则应提示用户输入注册码,进行注册  
              clickedok   :=   InputQuery('系统提示',   '请输入注册码:',   inputstr);  
              if   clickedok   then  
              begin  
                  get_id   :=   inttostr(83392582   *   2);   //注册码为166785164,够简单的......  
                  if   get_id   =   inputstr   then  
                  begin  
                      Writeinteger('gc_id',   0);         //若输入的注册码正确,则将标志值置为0,即已注册  
                      Application.MessageBox('恭喜你,软件注册成功!',   '提示',   MB_OK);  
                      CloseKey;  
                      Free;  
                  end  
                  else  
                  begin  
                      application.messagebox('注册码错误!请与作者联系!',   '警告',   mb_ok   +   mb_iconstop);  
                      CloseKey;  
                      Free;  
                      application.terminate;                                   //中止程序运行,拒绝让其继续使用  
                  end;  
              end  
              else  
              begin  
                  CloseKey;  
                  Free;  
                  application.terminate;                                       //中止程序运行,拒绝让其继续使用  
              end;  
          end;  
      end;  
      N:   datamodule1   :=   tdatamodule1.Create(self);  
      if   not   assigned(E_loginf)   then  
          E_loginf   :=   tE_loginf.Create(self);  
      E_loginf.ShowModal;  
      if   E_loginf.ModalResult   =   mrCancel   then//检查返回模式,如果是关闭或是取消,则中止运行  
      begin  
              Application.Terminate;  
              exit;  
      end;  
  不知有没达到你要求~~

抱歉!评论已关闭.