各位大虾,想请教一下,在软件中怎样实现注册功能,是否需要将注册信息做成一个类似与.reg的文件。
是否有实例说明.谢拉.

解决方案 »

  1.   

    procedure Tloginform.FormCreate(Sender: TObject);
    var
      re_id:integer;
      registerTemp : TRegistry;
      i,j,k:word;
      inputstr,get_id:string;
      dy:boolean;begin//软件注册
      dy:=false;
      registerTemp := TRegistry.Create;
      try
        with registerTemp do
        begin
            RootKey:=HKEY_LOCAL_MACHINE;
            if OpenKey('Software\Microsoft\Windows\CurrentVersion\Mark',True) then
            begin
              if valueexists('gc_id') then begin
                    re_id:=readinteger('gc_id');
                    if (re_id<>0) and (re_id<>100) then begin
                      msgboxi('软件未注册!请与开发商联系'+#13+'你目前还能用'+trim(inttostr(100-re_id+1))+'次');
                      re_id:=re_id+1;
                      Writeinteger('gc_id',re_id);
                    end;
                    if re_id=100 then dy:=true;
             end
             else Writeinteger('gc_id',5);
          end;
          if dy then begin
             Application.CreateForm(Tlogin_zcform, login_zcform);
             login_zcform.ShowModal;
             inputstr:=trim(login_zcform.zcm.Text);
             login_zcform.Free;
             DecodeDate(date,i,j,k);
             get_id:='aaa'+inttostr((i+j)*72);//注册码:aaa+(当前年+当前月)*72
             if get_id=inputstr then begin
                      Writeinteger('gc_id',0);
                      CloseKey;
    //                  Free;
              end
              else begin
                   msgboxi('注册码错误!请与作者联系!');
                   CloseKey;
    //             Free;
                   application.terminate;
             end;
          end;
        end;
     finally
        registerTemp.Free;
     end;end;