Send to Recycle Bin: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Updated author links.) |
m (Added category links.) |
||
Line 48: | Line 48: | ||
FunctionEnd | FunctionEnd | ||
</highlight-nsis> | </highlight-nsis> | ||
[[{{ns:14}}:Disk, Path & File Functions]] |
Revision as of 22:17, 30 April 2005
Author: Iceman_K (talk, contrib) |
Description
Silently send a file/files/directory to the Windows Recycle bin instead of permanantly deleting it. This function supports standard windows wildcards. The return value is pushed on the stack. A non-zero value indicates an error.
Usage
Push "c:\temp\xyz.txt" ; File to delete, supports wildcards Call SendToRecycleBin Pop $R0 ; Return code
The Function
Include the following code in your nsi file:
!ifndef FO_DELETE !define FO_DELETE 0x3 !endif !ifndef FOF_SILENT !define FOF_SILENT 0x4 !endif !ifndef FOF_NOCONFIRMATION !define FOF_NOCONFIRMATION 0x10 !endif !ifndef FOF_ALLOWUNDO !define FOF_ALLOWUNDO 0x40 !endif Function SendToRecycleBin Exch $R0 Push $R1 Push $R2 System::Alloc 28 Pop $R1 System::Call "*$R1(i $HWNDPARENT, i ${FO_DELETE}, t '$R0', t '', i ${FOF_ALLOWUNDO}|${FOF_SILENT}|${FOF_NOCONFIRMATION}, i 0, i 0, t '')" System::Call "shell32::SHFileOperationA(i R1)i.R2" System::Free $R1 StrCpy $R0 $R2 Pop $R2 Pop $R1 Exch $R0 FunctionEnd