Главная страница | назад





Article #17787: Sending a file to the Windows Recycle Bin?

 Question and Answer Database
FAQ2787D.txt Sending a file to the Windows Recycle Bin?
Category :Windows API
Platform :All
Product :All 32 bit
Question:
How do I send a file to the Windows Recycle Bin?
Answer:
Use the ShellAPI function SHFileOperation().
uses ShellAPI;
procedure SendToRecycleBin(FileName: string);
var
SHF: TSHFileOpStruct;
begin
with SHF do begin
Wnd := Application.Handle;
wFunc := FO_DELETE;
pFrom := PChar(FileName);
fFlags := FOF_SILENT or FOF_ALLOWUNDO;
end;
SHFileOperation(SHF);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SendToRecycleBin('c:\DownLoad\Test.gif');
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99