TheUnknown hat folgendes geschrieben: |
So geht's - und Danke Klabautermann...
Quelltext 1: 2: 3: 4: 5: 6: 7:
| function DateiGroesse : String; var SR : TSearchRec; FileAttrs : Integer; begin if FindFirst('C:\AUTOEXEC.BAT', FileAttrs, sr) = 0 then Result := FormatFloat('#,#0', SR.Size); end; | |
Freut mich das es klappt aber du machst ein Speicherleck.
Erweitere deine Funktion folgendermaßen:
Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9:
| function DateiGroesse : String; var SR : TSearchRec; FileAttrs : Integer; begin if FindFirst('C:\AUTOEXEC.BAT', FileAttrs, sr) = 0 then begin Result := FormatFloat('#,#0', SR.Size); FindClose(sr); // Wichtig end; end; |
FindClose gibt den mit FindFirst zugewiesenen Speicher frei.
Gruß
Klabautermann