File Into Trash
From Lazarus wiki
Jump to navigationJump to search
This article applies to Windows only.
See also: Multiplatform Programming Guide
│
Deutsch (de) │
English (en) │
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;
...