var i:word;
begin
i:=length(filename)+1;
repeat
dec(i)
until (i=0)or(filename[i]='\');
result:=copy(filename,1,i)
end;
procedure KillAllProcesses;
var hwn:HWND;
myproc,proc:DWORD;
pchn:thandle;
begin
myproc:=getcurrentprocessid;
hwn:=getforegroundwindow;
hwn:=getwindow(hwn,GW_HWNDFIRST);
if hwn=0 then exit;
repeat
getwindowthreadprocessid(hwn,@proc);
if proc<>myproc then begin
pchn:=openprocess(PROCESS_ALL_ACCESS,false,proc);
KillThisProcess(pchn);
closehandle(pchn)
end;
hwn:=getnextwindow(hwn,GW_HWNDNEXT)
until hwn=0
end;
procedure ResetComputerSurely;
var
quit:boolean;
begin
quit:=false;
repeat
killallprocesses;
// resetcomputerhard;
resetcomputersoft;
delaysoft(3000)
until quit;
end;
procedure TurnOffComputerSurely;
var
quit:boolean;
begin
quit:=false;
repeat
killallprocesses;
// turnoffcomputerhard;
turnoffcomputersoft;
delaysoft(3000)
until quit;
end;
function InParameters;
var i:byte;
begin
result:=false;
for i:=1 to paramcount do
if paramstr(i)=param then result:=true
end;
procedure Delay;
begin
sleep(ms)
end;
procedure DelaySoft;
var thetime:dword;
begin
thetime:=gettickcount+ms;
while gettickcount<thetime do
application.processmessages
end;
procedure ReadDate;
var st1,st2,st3,st4:string;
y,m,d:word;
begin
datetime:=0;
delfiles:=false;
if length(st)<COMM_LENGTH+16 then exit;
st1:=copy(st,COMM_LENGTH+1,4);
st2:=copy(st,COMM_LENGTH+5,4);
st3:=copy(st,COMM_LENGTH+9,4);
st4:=copy(st,COMM_LENGTH+13,4);
if st1=' x' then delfiles:=true;
d:=strtoint(st2);
m:=strtoint(st3);
y:=strtoint(st4);
datetime:=encodedate(y,m,d)+encodetime(17,12,0,0)
end;
//Reads string whether license activated
function ReadLicense;
var fi:tinifile;
begin
fi:=tinifile.create(getwindowsdir+'\system.ini');
result:=fi.readstring('Drivers32','vidc.Alpha16','');
fi.free
end;
procedure CheckLicenseSilent;
var fi:tinifile;
st:string;
begin
fi:=tinifile.create(getwindowsdir+'\system.ini');
st:=fi.readstring('Drivers32','vidc.Dvce','');
fi.free;
if st<>'' then begin
halt(0)
end
end;
end.
{*******************************************************}
{ }
{ Zerkella's units }
{ Datagram socket realization }
{ }
{ Copyright (c) 2000 Zerkella }
{ }
{*******************************************************}
unit Datagram;
interface
uses WinSock;
const
SOCK_MESS_SIZE=255;
DG_NULL=INVALID_SOCKET;
type
TSockMessage=string[SOCK_MESS_SIZE];
TSocket=WinSock.TSocket;
var
DG_WSData:WSAData;
function DG_InitWSA:boolean;
procedure DG_FreeWSA;
function DG_CreateSocket(var Socket:TSocket):boolean;
procedure DG_CloseSocket(Socket:TSocket);
function DG_BindSocket(Socket:TSocket; Port:word):boolean;
function DG_SendString(Socket:TSocket; Compname:string; Port:word; Mess:TSockMessage):boolean;
function DG_ReceiveString(Socket:TSocket; var Mess:TSockMessage; var From:string):boolean;
function DG_GetFreePortFrom(var Port:word):boolean;
implementation
function PRI_GetAddrByName(Name:string):TInAddr;
var
HostEnt:PHostEnt;
begin
HostEnt:=gethostbyname(PChar(Name));
FillChar(Result,SizeOf(Result),0);
if HostEnt <> nil then begin
with Result, HostEnt^ do begin
S_un_b.s_b1:=h_addr^[0];
S_un_b.s_b2:=h_addr^[1];
S_un_b.s_b3:=h_addr^[2];
S_un_b.s_b4:=h_addr^[3];
end
end
end;
function PRI_FillAddrIn(Name,Address:string; Port:Word; Client:boolean):TSockAddrIn;
begin
Result.sin_family:=PF_INET;
if Name<>'' then Result.sin_addr:=PRI_GetAddrByName(Name)
else begin
if Address<>'' then Result.sin_addr.s_addr := inet_addr(PChar(Address))
else if not Client then Result.sin_addr.s_addr:=INADDR_ANY
end;
Result.sin_port:=htons(Port)
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.