home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Intermedia 1998 January
/
inter1_98.iso
/
www
/
rozi
/
PROTECT.ZIP
/
STARTER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-06-08
|
2KB
|
94 lines
uses instu,dos;
const pop=0;
zamek=1;
niepop=2;
function openfileandtest(filename:pathstr; reclen:longint; var f:file):byte;
begin
assign(f,filename);
{$I-}
reset(f,1);
{$I+}
if ioresult<>0 then
begin
openfileandtest:=zamek;
exit;
end;
if (filesize(f) mod reclen)<>0 then
begin
openfileandtest:=niepop;
close(f);
exit;
end;
close(f);
assign(f,filename);
{$I-}
reset(f,reclen);
{$I+}
if ioresult<>0 then
begin
openfileandtest:=zamek;
exit;
end;
openfileandtest:=pop;
end;
var dane:tdaneinst;
f:file of tdaneinst;
f1:file;
s:string;
i:byte;
begin
if openfileandtest(instfile,sizeof(tdaneinst),file(f))<>pop then
begin
writeln('Uszkodzony plik: ',instfile,' !');
halt;
end;
read(f,dane);
close(f);
rev(dane.biosdate);
if (dane.machinetype<>machinetype) or (dane.biosdate<>databios) then
begin
writeln('Nielegalna kopia programu: ',dane.nazwa,' !');
halt;
end;
assign(f1,dane.nazwa);
{$I-}
reset(f1,1);
{$I+}
if ioresult<>0 then
begin
writeln('Nie moge otworzyc pliku: ',dane.nazwa,' !');
halt;
end;
if filesize(f1)<200 then i:=filesize(f1)
else i:=200;
seek(f1,0);
blockread(f1,s,i);
rev(s);
seek(f1,0);
blockwrite(f1,s,i);
close(f1);
swapvectors;
exec(dane.nazwa,'');
swapvectors;
if doserror<>0 then
writeln('Blad DOS nr: ',doserror);
assign(f1,dane.nazwa);
{$I-}
reset(f1,1);
{$I+}
if ioresult<>0 then
begin
writeln('Nie moge otworzyc pliku: ',dane.nazwa,' !');
halt;
end;
if filesize(f1)<200 then i:=filesize(f1)
else i:=200;
seek(f1,0);
blockread(f1,s,i);
rev(s);
seek(f1,0);
blockwrite(f1,s,i);
close(f1);
end.