S
shijiesun
Unregistered / Unconfirmed
GUEST, unregistred user!
一段智能识别软件试用时间的代码
procedure TForm2.FormCreate(Sender:TObject);
var
inifile:TIniFile;
CurTime,TerTime:TDateTime;
begin
if FileExists(Trim(ExtractFilePath(Application.ExeName)+'register.ini'))=True then
begin
Try
inifile:=TIniFile.Create(Trim(ExtractFilePath(Application.ExeName))+'register.ini');
CurTime:=inifile.ReadDateTime('注册信息','当前时间',now);
TerTime:=inifile.ReadDateTime('注册信息','终止时间',now);
if CurTime>=TerTime then
begin
Application.MessageBox('软件已经过期.','提示',64);
Application.Terminate;
end
else
begin
if Trunc(CurTime)>Trunc(Now) then
begin
Application.Terminate;
end
else
begin
if (Trunc(Now)-Trunc(CurTime))>1 then
begin
TerTime:=terTime+Trunc(Now)-Trunc(CurTime)-1;
Inifile.WriteDateTime('注册信息','终止时间',terTime);
end;
CurTime:=Trunc(Now);
end;
inifile.WriteDateTime('注册信息','当前时间',CurTime);
Label5.Caption:=IntToStr(Trunc(Tertime)-Trunc(CurTime))+'天'
end;
Finally
inifile.Free;
end;
end
else
begin
Try
inifile:=TIniFile.Create(Trim(ExtractFilePath(Application.ExeName))+'register.ini');
with Inifile do
begin
WriteDateTime('注册信息','起始时间',Trunc(Now));
WriteDateTime('注册信息','当前时间',Trunc(Now));
WriteDateTime('注册信息','终止时间',Trunc(Now)+30);
end;
Finally
Inifile.Free;
End;
Label5.Caption:='30天'
end;
end;
编译不能通过,显示:Undeclared identifier:'TiniFile'
procedure TForm2.FormCreate(Sender:TObject);
var
inifile:TIniFile;
CurTime,TerTime:TDateTime;
begin
if FileExists(Trim(ExtractFilePath(Application.ExeName)+'register.ini'))=True then
begin
Try
inifile:=TIniFile.Create(Trim(ExtractFilePath(Application.ExeName))+'register.ini');
CurTime:=inifile.ReadDateTime('注册信息','当前时间',now);
TerTime:=inifile.ReadDateTime('注册信息','终止时间',now);
if CurTime>=TerTime then
begin
Application.MessageBox('软件已经过期.','提示',64);
Application.Terminate;
end
else
begin
if Trunc(CurTime)>Trunc(Now) then
begin
Application.Terminate;
end
else
begin
if (Trunc(Now)-Trunc(CurTime))>1 then
begin
TerTime:=terTime+Trunc(Now)-Trunc(CurTime)-1;
Inifile.WriteDateTime('注册信息','终止时间',terTime);
end;
CurTime:=Trunc(Now);
end;
inifile.WriteDateTime('注册信息','当前时间',CurTime);
Label5.Caption:=IntToStr(Trunc(Tertime)-Trunc(CurTime))+'天'
end;
Finally
inifile.Free;
end;
end
else
begin
Try
inifile:=TIniFile.Create(Trim(ExtractFilePath(Application.ExeName))+'register.ini');
with Inifile do
begin
WriteDateTime('注册信息','起始时间',Trunc(Now));
WriteDateTime('注册信息','当前时间',Trunc(Now));
WriteDateTime('注册信息','终止时间',Trunc(Now)+30);
end;
Finally
Inifile.Free;
End;
Label5.Caption:='30天'
end;
end;
编译不能通过,显示:Undeclared identifier:'TiniFile'