Sign in Join
Wiki copytemporary

File Into Trash: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: File Into Trash

OldNewLine
1+This article deals with Windows programming. This function moves a file to the trash (recycle) bin.
2+
3+``` pascal
4+uses
5+ ShellAPI,
6+ FileUtil;
7+
8+ ...
9+
10+function FileIntoTrashBin(strFilename : string) : boolean;
11+var
12+ fileStructure : TSHFileOpStruct;
13+begin
14+ FillChar(fileStructure, SizeOf(fileStructure), 0);
15+
16+ with fileStructure do
17+ begin
18+ wFunc := FO_DELETE ;
19+ // Allows umlauts etc. in the file name
20+ pFrom := PChar(UTF8ToSys(strFilename));
21+ fFlags := FOF_ALLOWUNDO + FOF_NOCONFIRMATION + FOF_SILENT;
22+ end;
23+
24+ Result := ShFileOperation(fileStructure) = 0;
25+end;
26+
27+ ...
28+```
29+
30+---
31+*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](/wiki-contact).*

Back to history