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

end

end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);

begin

canclose:=cancloseform

end;

procedure SetCaption;

begin

UpdateFace;

if (cl_networkon)and(net.timeto=0)and(not net.forevertime) then setdoplatitemode

else unsetdoplatitemode

end;

end.

unit Common;

interface

uses  Windows, SysUtils, Inifiles, Registry, Dialogs, Classes, Forms, WinSock, Messages;

const

//Version

VERSION='v2.2';

MADE_FOR='VIRUS2';

//Max number of buttons

MAXBUTTNUM=150;


 




//Type of button

TB_FILE='__Программа__';

TB_ADMIN='__Администрирование__';

TB_FOLDER='__Папка__';

//Standart icons for files

ICO_NOTFOUND='notfound.ico';

ICO_ADMIN='admin.ico';

ICO_FOLDER='folder.ico';

//Errors

SUCCESSFUL='Успешно';

ERR_BADFORMAT='Неправильный формат';

//Infos

INF_NOTFOUND='Не найдено';

//Resource strings

RES_ADMIN='Администрирование';

CURRENCY_HRN='грн';

CURRENCY_COP='коп';

//Defaults

DEFAULT_PASSWORD='0p';

DEFAULT_PORT=23905;

DEFAULT_SERVERPORT=23910;

ZSHELL_TIMERSEC=25000;

UPDATE_FLUSHFILE='flushed.tmp';

UPDATE_COPYSTRINGFILE='update32.txt';

//Messages

WM_OPENWINDOW=WM_USER+3;

WM_NOTIFYTRAY=WM_USER+4;

//Network constants

COMM_LENGTH=6;

SOCKETS_READ_MSEC=500;

TIME_FOREVER='НАВСЕГДА';

//Network messages from server

COMM_TIME=       'TIME  ';

COMM_SYNCTIME=   'SYNC  ';

COMM_RESET=      'RESET ';

COMM_TURN_OFF=   'TURN  ';

COMM_ECHO=       'ECHO  ';

COMM_ACCEPTED=   'ACCPT ';

COMM_UPDATE=     'UPDAT ';

COMM_PASSWORD=   'PASSW ';

//Network messages from client

COMM_READY=      'FREE  ';

COMM_ONLINE=     'ONLIN ';

COMM_ADMINON=    'ADMON ';

COMM_ADMINOFF=   'ADMOFF';

//Network messages from server and client

COMM_OFFLINE=    'OFLIN ';

//Commandline parameters

SERV_NOSPLASH='-nosplash';

SERV_MINIMIZE='-minimize';

CLIENT_RESTOREFLUSHED='-restore';

type

//Info for button

prog_info=record

name:string;

filename:string;

icon:string;

wherecopy:string;

whoseconfig:string;

itstype:string;

internet:boolean;

loadtype:integer//used by zshell

end;

var

//All the registered buttons

pgs:array [1..MAXBUTTNUM] of prog_info;

numbuttons:integer;

path:string;

//Client only

cl_networkon:boolean;

cl_servername:string;

cl_port:word;

cl_zshellport:word;

zoptions:record

exploreroff:boolean;

yeserrors:boolean

end;

procedure HideMe;

procedure KillTaskman;

procedure RestoreTaskman;

function DetectedNT:boolean;

procedure DelaySoft(ms:dword);

procedure Delay(ms:dword);

function RunIt(appname,cmdline:string):_process_information;

function GetWindowsDir:string;

function ReadLicense:string;

procedure ReadDate(st:string;var delfiles:boolean;var datetime:tdatetime);

procedure SetLicense(comm:string);

function GetFilePath(filename:string):string;

function GetFolder(filename:string):string;

procedure ActionLicense(delfiles:boolean;datetime:tdatetime);

procedure CheckLicense;

procedure CheckLicenseSilent;

function InParameters(param:string):boolean;

procedure KillThisWindow(hwn:hwnd);

procedure KillThisProcess(pchn:THandle);

procedure SetRegStringKey(ROOT_KEY:HKEY;KeyPath,KeyName,Value:string);

procedure InstallShell;

procedure UninstallShell;

function GetMinsFromZero(datetime:tdatetime):cardinal;

implementation

const

//compinnet values

CMP_UNKNOWN=0;

CMP_NOTINNET=1;

CMP_INNET=2;

var logcreated:boolean=false;

procedure ResetComputerSoft; forward;

procedure ResetComputerHard; forward;


 




procedure TurnOffComputerSoft; forward;

procedure TurnOffComputerHard; forward;

procedure KillThisProcess;

begin

terminateprocess(pchn,0)

end;

procedure KillThisWindow;

var pcid:dword;

pchn:thandle;

begin

getwindowthreadprocessid(hwn,@pcid);

pchn:=openprocess(PROCESS_ALL_ACCESS,false,PcId);

KillThisProcess(pchn);

closehandle(pchn)

end;

//From a full path to file with filename

//returns only path to file with '\' in

//the end

function GetFilePath;