unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ShellApi; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Label1: TLabel; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Edit1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var FileInfo : SHFILEOPSTRUCT; begin If Not FileExists(Edit1.Text) Then Showmessage('filen finns inte'); with FileInfo do begin Wnd := Handle; wFunc := FO_DELETE; pFrom := PChar(Edit1.Text); pTo := nil ; fFlags := FOF_ALLOWUNDO; lpszProgressTitle := ''; end; SHFileOperation(FileInfo); end; procedure TForm1.Edit1Click(Sender: TObject); begin Edit1.Clear end; end.