1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, shellapi, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) ListBox1: TListBox; Label1: TLabel; Memo1: TMemo; Label2: TLabel; LBzahl: TLabel; LBzahl1: TLabel; Lbgreen: TLabel; ListBox2: TListBox; LBYellow1: TLabel; LBYellow2: TLabel; ListBox3: TListBox; procedure FormCreate(Sender: TObject); private public end;
var Form1: TForm1; nFileCount : integer;
implementation
procedure GetFilesInDirectory(Directory: string; const Mask: string; List: TStrings; WithSubDirs, ClearList: Boolean);
procedure ScanDir(const Directory: string); var SR: TSearchRec; begin if FindFirst(Directory + Mask, faAnyFile and not faDirectory, SR) = 0 then try repeat List.Add(Directory + SR.Name) until FindNext(SR) <> 0; finally FindClose(SR); end;
if WithSubDirs then begin if FindFirst(Directory + '*.*', faAnyFile, SR) = 0 then try repeat if ((SR.attr and faDirectory) = faDirectory) and (SR.Name <> '.') and (SR.Name <> '..') then ScanDir(Directory + SR.Name + '\'); until FindNext(SR) <> 0; finally FindClose(SR); end; end; end;
begin List.BeginUpdate; try if ClearList then List.Clear; if Directory = '' then Exit; if Directory[Length(Directory)] <> '\' then Directory := Directory + '\'; ScanDir(Directory); finally List.EndUpdate; end; end;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject); var F:textfile; var zahl, zahl2, zahl3 , i, x :integer;
begin GetFilesInDirectory('C:\','*.exe', Listbox1.Items, true,false); Lbzahl.caption:= IntToStr (Listbox1.items.count); zahl:=Listbox1.items.count;
if FileExists ('C:\Anzahl.txt') then try memo1.lines.Loadfromfile('C:\Anzahl.txt'); LBzahl1.caption:=memo1.lines[0]; EXCEPT ShowMessage ('Fehler beim Laden der Datei!'); end;
zahl2:=strtoint(lbzahl1.caption);
if zahl = zahl2 then begin LBgreen.visible:=true; end
else if zahl > zahl2 then begin form1.top:=650; form1.height:=305; listbox3.visible:=true; Zahl3:=zahl-zahl2; LBYellow1.visible:=true; LBYellow1.caption:=inttostr(zahl3); LBYellow2.visible:=true; ListBox2.Items.LoadFromFile('C:\ExeFiles.txt');
for i := 0 to ListBox1.Items.Count - 1 do begin if (ListBox2.Items.IndexOf(ListBox1.Items[i])=-1) then ListBox3.Items.Add(ListBox1.Items.Strings[i]); end;
end
else if zahl < zahl2 then begin
end;
if not FileExists ('C:\Exefiles') then
begin AssignFile(F, 'C:\ExeFiles.txt'); {$i-} Rewrite(F);
FOR x := 0 TO ListBox1.Items.Count-1 DO Writeln (F, ListBox1.Items[x]); CloseFile(F); {$I+} end;
if not FileExists ('C:\Anzahl.txt') then begin AssignFile(F, 'C:\Anzahl.txt'); {$i-} rewrite(f); Writeln(F, zahl); {$I+} closefile(f); end;
end;
end. |