I would like help.
I have the routine below that it works well in Delphi with Win.3.11, but it
doesn't work in
win.95/98. I believe that a difference exists among Win.3.11 win.95/98 when
it negotiates
numbers and string.
The routine below is used to limit the amount of times that a software can
be used.
of course !
Tks
Fernando.
-----------------------------------------------------
unit Unit1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
procedure FormActivate(Sender: TObject);
function Protect(QtProt:byte) : boolean;
private
{ Private declarations }
// function Protect(QtProt:byte) : boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{---------------------------------------------------------------------------
function TForm1.Protect(QtProt:byte) : boolean;
type
tcfg = record
id : string[10]; { badge to identify }
val: byte;
end;
const
{ Id , Any string. To be researched inside of the file .EXE }
cfg : tcfg = (id:'$2Act?2?'; val:4);
var
lixo : string[10];
f : file;
i : longint;
begin;
Label1.Caption := 'They still remain: ' +
inttostr(cfg.val) +
'Executions of a total of 4';
if cfg.val > 0 then
begin
lixo := '';
{$I-}
assignfile(f, paramstr(0));
reset(f, 1);
i := filesize(f) - sizeof(cfg);
{$I+}
{ I seek the badge. }
while (i > 0) and (lixo <> '$2Act?2?') do
begin
seek(f, i);
blockread(f, lixo, sizeof(lixo));
dec(i);
end;
if (i > 0) then
begin { If I found the badge... }
seek(f, succ(i));
if (cfg.val > 0) then
begin
dec(cfg.val);
blockwrite(f, cfg, sizeof(cfg));
end;
end;
{$I-}
closefile(f);
Protect := false;
{$I+}
end else
Protect := True;
end;
{---------------------------------------------------------------------------
procedure TForm1.FormActivate(Sender: TObject);
begin
if Protect(4) then
Label2.Caption := 'ATTENTION: It cannot Be executed'
else
Label2.Caption := 'Allowed execution';
end;
{---------------------------------------------------------------------------
end.