本例中TRegistry是關鍵類
程序第一次運行就寫入其運行時間
密碼的變換函數
一
procedure TForm
var
Reg:Tregistry;
KeyName
Same:Integer;
FirstDate
NumberOfDays:real;
begin
NoRegistry:=true;
NowDate:=date; //取得運行時系統日期
try
//創建注冊表
Reg:=Tregistry
Reg
KeyName:=
if Reg
begin
TempName:=Reg
TempCode:=Reg
//讀取用戶名
try
FirstDate:=Reg
//非第一次則讀入第一次運行時間
except
Reg
// 若為第一次運行
FirstDate:=NowDate;
end;
end ;
reg
finally
reg
end;
TempStr:=Encrypt(TempName);
//通過自定義函數Encrypt()來獲取密碼
Same:=CompareText(TempStr
//比較密碼
if TempName<>
if Same=
NoRegistry:=false;
//驗證密碼
if NoRegistry then
begin //若未注冊
NumberOfDays:=Nowdate
SpareDays:=round(
Label
if((NumberOfDays>
begin
showmessage(
application
end;
end;
end;
二
procedure TAbout
var
InptName
Same:Integer;
Reg:Tregistry;
Keyname:String;
begin
if NoRegistry then //未注冊時做
begin
RealCode:=
InptName:= InputBox(
if InptName<>
begin
InptCode:= InputBox(
RealCode:=Encrypt(InptName);
Same:=CompareText(RealCode
if (Same<>
showmessage(
else
begin
//密碼匹配時做
Try
Reg:=Tregistry
Reg
KeyName:=
if Reg
begin
Reg
Reg
end;
reg
finally
Reg
end;
NoRegistry:=false;
//可修改注冊後的界面
end;
end;
end;
end;
三
Function TForm
Var
Str
i
Begin
Str
For i:=
begin
j:=(i?i?i?i mod (i+
Str
j:=(i?i?i?i mod (i+
Str
End;
Result:=Str
end;
此程序在Windows
From:http://tw.wingwit.com/Article/program/Delphi/201311/8395.html