Програмне забезпеченння для адміністрування комп'ютерного клубу, страница 10

procedure UpdateFace;

var sth,stm:string;

min1,min2:integer;

now1:tdatetime;

begin

form1.minet.caption:='';

form1.mitime.caption:='';

if cl_networkon then begin

if net.connected then form1.miNet.caption:='-|-';

if net.forevertime then form1.mitime.caption:='*'

else begin

now1:=now;

if net.timeto>now1 then begin

min1:=getminsfromzero(now1);

min2:=getminsfromzero(net.timeto);

min1:=min2-min1;

sth:=inttostr(min1 div 60);

stm:=inttostr(min1 mod 60);

if length(stm)=1 then stm:='0'+stm;

form1.mitime.caption:=sth+':'+stm

end

end

end

end;

//Terminates new processes

procedure DestroyNewProcesses;

var snp:THandle;

pchn:THandle;

ok:boolean;

pe:processentry32;

begin

snp:=createsnapshot;

ok:=getfirstprocess(snp,pe);

while ok do begin

if not itssavedprocess(pe.th32ProcessID) then begin

pchn:=openprocess(PROCESS_ALL_ACCESS,false,pe.th32ProcessID);

KillThisProcess(pchn);

closehandle(pchn)

end;

ok:=getnextprocess(snp,pe)

end;

closesnapshot(snp)

end;

procedure SetDoplatiteMode;

var i:word;

hwn:hwnd;

oldvalue:longbool;

showmessage:boolean;

begin

if not cl_networkon then exit;

if AdminOn then exit;

//Hide copyfiles

if (copyfilescreated)and(copyfiles.visible) then begin

copyfiles.modalresult:=mrCancel;

copyfiles.Hide

end;

//Restore Windows mode

SystemParametersInfo(SPI_SCREENSAVERRUNNING,Word(True),@OldValue,0);

if not application.active then begin

hwn:=getforegroundwindow;

closewindow(hwn);

application.bringtofront;

delay(2000)

end;

//Send WM_QUIT to processes

showmessage:=false;

if sendquits then begin

showmessage:=true;




delay(4000);

checkclosedprocesses(false)

end;

form1.Refresh;

//Close processes that are started from

//ZShell

if numpcs>0 then begin

for i:=1 to numpcs do

KillThisProcess(pcs[i].handle);

delay(600);

checkclosedprocesses(false)

end;

//Close all new processes

DestroyNewProcesses;

if numpcs>0 then begin

delay(500);

checkclosedprocesses(true)

end;

nullexplorers;

//Set doplatite mode

updateface;

if showmessage then MessageDoplatite;

if not(getpriorityclass(getcurrentprocess)=REALTIME_PRIORITY_CLASS) then

setpriorityclass(getcurrentprocess,REALTIME_PRIORITY_CLASS)

end;

procedure UnSetDoplatiteMode;

var oldvalue:longbool;

begin

if not cl_networkon then exit;

SystemParametersInfo(SPI_SCREENSAVERRUNNING,Word(False),@OldValue,0);

setpriorityclass(application.handle,NORMAL_PRIORITY_CLASS)

end;

function ComposeWinName:string;

begin

result:='ZShell '+VERSION+'    Made by Zerkella'

end;

function PreviousRun;

var classname,winname:string;

begin

classname:='TForm1';

winname:=composewinname;

if findwindow(pchar(classname),pchar(winname))<>0 then result:=true

else result:=false

end;

//Checks whether window cannot be closed

//or can

function ItsOldWindow(hwndnew:hwnd):boolean;

var proc:dword;

begin

getwindowthreadprocessid(hwndnew,@proc);

result:=ItsSavedProcess(proc)

end;

procedure CreateButton(ind:integer);

begin

buttons[ind]:=ttoolbutton.create(form1.toolbar);

buttons[ind].parent:=form1.toolbar;

buttons[ind].ImageIndex:=ind-1;

buttons[ind].showhint:=true;

buttons[ind].hint:=pgs[ind].name;

buttons[ind].onclick:=form1.tbclick

end;

procedure Trap;

begin

killtaskman

end;

procedure ConnectSocket;

var st:TSockMessage;

begin

st:=COMM_ONLINE+inttostr(cl_zshellport);

if cs<>DG_NULL then

DG_SendString(cs,cl_servername,cl_port,st)

end;

procedure StartNetwork;

begin

cs:=DG_NULL;

if not DG_InitWSA then begin

showmessage('Не удается запустить сеть, проверьте настройки протокола TCP/IP');

exit

end;

DG_CreateSocket(cs);

if not DG_BindSocket(cs,cl_zshellport) then begin

showmessage('Не удается запустить сетевой порт, попробуйте изменить его номер');

DG_CloseSocket(cs);

cs:=DG_NULL;

exit

end;

connectsocket

end;

procedure CloseNetwork;

begin

net.connected:=false;

if cs<>DG_NULL then DG_CloseSocket(cs);

cs:=DG_NULL;

DG_FreeWSA;

updateface