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
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ShellApi, StdCtrls;
type
TForm1 = class(TForm)
procedure Timer1Timer(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function OldestFile(const Dossier, Template: string): TFilename;
var
Info: TSearchRec;
CurrentTime: Integer;
begin
result := '';
if FindFirst(Dossier + Template, 0, Info) = 0 then
begin
repeat
if (result = '') or
(Info.Time < CurrentTime) then
begin
result := Info.Name;
CurrentTime := Info.Time;
end;
until FindNext(Info) <> 0;
FindClose(Info);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Interval :=30000;
DeleteFile(OldestFile('D:\Nouveau dossier\','*.bmp'));
end;
end. |
Partager