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

threadinfo.dwSize:=sizeof(threadinfo);

result:=thread32next(snp,threadinfo)

end;

//Returns a stringlist with threadIds,

//that belong to specified process

procedure GetThreadListForProcess;

var ok:boolean;

te:threadentry32;

begin

stList.clear;

ok:=getfirstthread(snp,te);

while ok do begin

if te.th32OwnerProcessID=ProcessId then stList.add(inttostr(te.th32ThreadID));

ok:=getnextthread(snp,te)

end

end;

//From a snapshot gets an info about a specified process

function GetProcessInfoById;

begin

processinfo.dwSize:=sizeof(processinfo);

result:=process32first(snp,processinfo);

if (result=false)or(processinfo.th32ProcessID=processid) then exit;

repeat

result:=process32next(snp,processinfo)

until (result=false)or(processinfo.th32ProcessID=processid)

end;

//From a snapshot gets an info specified by its

//number in snapshot

function GetProcessInfoByNumber;

var n:cardinal;

begin

processinfo.dwSize:=sizeof(processinfo);

n:=1;

result:=process32first(snp,processinfo);

if (result=false)or(num=1) then exit;

repeat

result:=process32next(snp,processinfo);

inc(n)

until (result=false)or(n=num)

end;

//Checks whether flushfile created less

//than or five munutes ago

function FineTime;

var flushed:file of dword;

dt:array [1..7] of dword;

i:byte;




minsnow,minsthatdate:dword;

thatdate:tdatetime;

begin

result:=true;

if not fileexists(path+UPDATE_FLUSHFILE) then begin

result:=false;

exit

end;

assign(flushed,path+UPDATE_FLUSHFILE);

reset(flushed);

for i:=1 to 7 do

read(flushed,dt[i]);

close(flushed);

thatdate:=encodedate(dt[1],dt[2],dt[3]);

thatdate:=thatdate+encodetime(dt[4],dt[5],dt[6],dt[7]);

minsnow:=getminsfromzero(now);

minsthatdate:=getminsfromzero(thatdate);

if minsnow-minsthatdate>5 then result:=false

end;

//Completes a list of processes that are

//not terminated when user's time ends

procedure CompleteSavedProcesses;

var flushed:file of dword;

mus:dword;

i:word;

snp:THandle;

ok:boolean;

pe:processentry32;

begin

numaprocesses:=0;

if InParameters(CLIENT_RESTOREFLUSHED)and(finetime) then begin

assign(flushed,path+UPDATE_FLUSHFILE);

reset(flushed);

seek(flushed,7);

read(flushed,mus);

seek(flushed,8+mus);

read(flushed,mus);

numaprocesses:=mus;

for i:=1 to numaprocesses do

read(flushed,aprocesses[i]);

close(flushed)

end

else begin

snp:=createsnapshot;

ok:=getfirstprocess(snp,pe);

while ok do begin

inc(numaprocesses);

aprocesses[numaprocesses]:=pe.th32ProcessID;

ok:=getnextprocess(snp,pe)

end;

closesnapshot(snp)

end

end;

//Retuirns whether process is a saved one

function ItsSavedProcess;

var i:word;

begin

result:=false;

i:=1;

while (i<=numaprocesses)and(not result) do begin

if aprocesses[i]=processid then result:=true;

inc(i)

end

end;

end.

unit CopyFilesUnit;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls;

type

TCopyFiles = class(TForm)

ListBox: TListBox;

CopyButton: TButton;

Button2: TButton;

procedure ListBoxClick(Sender: TObject);

procedure CopyButtonClick(Sender: TObject);

procedure FormCreate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

const

MAXCOPIED=300;

var

CopyFiles: TCopyFiles;

numcopied:word;

copied:array [1..MAXCOPIED] of string;

copyfilescreated:boolean=false; 

procedure InitCopying(destdir,maindir:string);

procedure DeleteCopied;

implementation

{$R *.DFM}

uses Common,MainUnit;

var numfiles,numdirs:word;

dirs:array [1..500] of string;

files:array [1..2000] of string;

bigdir,currdir,ddir:string;

function Earlier(st1,st2:string):boolean;

var i:integer;

found:boolean;

orded1,orded2:byte;

begin

i:=1;

found:=false;

Earlier:=false;

st1:=AnsiLowerCase(st1);

st2:=AnsiLowerCase(st2);

if st1=st2 then begin

earlier:=false;

exit

end;

while (not found)and(i<=length(st1))and(i<=length(st2)) do begin

orded1:=ord(st1[i]);

orded2:=ord(st2[i]);

if orded1<orded2 then begin