File Into Trash
Deutsch ยท English
This article deals with Windows programming. This function moves a file to the trash (recycle) bin.
uses
ShellAPI,
FileUtil;
...
function FileIntoTrashBin(strFilename : string) : boolean;
var
fileStructure : TSHFileOpStruct;
begin
FillChar(fileStructure, SizeOf(fileStructure), 0);
with fileStructure do
begin
wFunc := FO_DELETE ;
// Allows umlauts etc. in the file name
pFrom := PChar(UTF8ToSys(strFilename));
fFlags := FOF_ALLOWUNDO + FOF_NOCONFIRMATION + FOF_SILENT;
end;
Result := ShFileOperation(fileStructure) = 0;
end;
...From the Free Pascal wiki, page "File Into Trash", as it stood on 2020-02-15 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.