怎么回事,说函数出错,请各位看看这段代码(10分)

  • 主题发起人 主题发起人 dreamblue
  • 开始时间 开始时间
D

dreamblue

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,registry;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }

end;

var
Form1: TForm1;
NoRegistry:Boolean;
SpareDays:integer;
Function TForm1.Encrypt(TempStr:string):string;

implementation

{$R *.DFM}
Function TForm1.Encrypt(TempStr:string):string;

Var

Str1:String;

i,j:Integer;

Begin

Str1:='';

For i:=1 to Length(TempStr) do

begin

j:=(i?i?i?i mod (i+30))+(i?i mod (i+20))+i?3+1;

Str1:=Str1+chr(ord(TempStr)+j);

j:=(i?i?i?i mod (i+30))+(i?i mod (i+20))+i?3+1;

Str1:=Str1+chr(ord(TempStr)+j);

End;

Result:=Str1;

end;



procedure TForm1.FormCreate(Sender: TObject);

var

Reg:Tregistry;

KeyName,TempCode,TempName,TempStr:string;

Same:Integer;

FirstDate,NowDate:Tdatetime;

NumberOfDays:real;

begin

NoRegistry:=true;

NowDate:=date; //取得运行时系统日期

try

//创建注册表,有该键则读取,无则创建

Reg:=Tregistry.Create ;

Reg.RootKey :=hkey_local_machine;

KeyName:='Software/jsjb/Example';

if Reg.OpenKey(KeyName,true) then

begin

TempName:=Reg.ReadString('UsrName');

TempCode:=Reg.ReadString('Passwd');

//读取用户名,注册号

try

FirstDate:=Reg.ReadDate('Date');

//非第一次则读入第一次运行时间

except

Reg.WriteDate('Date',NowDate);

// 若为第一次运行,则写入系统日期

FirstDate:=NowDate;

end;

end ;

reg.CloseKey ;

finally

reg.Free ;

end;

TempStr:=Encrypt(TempName);

//通过自定义函数Encrypt()来获取密码

Same:=CompareText(TempStr,TempCode);

//比较密码

if TempName<>'' then

if Same=0 then

NoRegistry:=false;

//验证密码,通过NoRegistry为false

if NoRegistry then

begin //若未注册...

NumberOfDays:=Nowdate-FirstDate;

SpareDays:=round(31-NumberOfDays);

Label1.Caption :=FloatToStr(SpareDays);

if((NumberOfDays>31) or (NumberOfDays<-1)) then

begin

showmessage('程序未注册超过试用期或更改系统时间,将终止运行!');

application.Terminate;//超过30天,则禁止运行
end;

end;



end;

end.
 
....
var
Form1: TForm1;
NoRegistry:Boolean;
SpareDays:integer;
Function TForm1.Encrypt(TempStr:string):string; //有这种申明法吗?

implementation
.....
 
再看看Encrypt下的语句!
错得离谱!
抄程序也抄得好看些。
 
函数声明 Function TForm1.Encrypt(TempStr:string):string;
改为 Function Encrypt(TempStr:string):string;
 
多人接受答案了。
 
后退
顶部