Send to Recycle Bin: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Adding new author and category links.)
(sitdro)
Line 6: Line 6:
The return value is pushed on the stack. A non-zero value indicates an error.
The return value is pushed on the stack. A non-zero value indicates an error.


== Usage ==
relbocletoc
<highlight-nsis>
Push "c:\temp\xyz.txt" ; File to delete, supports wildcards
Call SendToRecycleBin
Pop $R0 ; Return code
</highlight-nsis>


== The Function ==
== The Function ==

Revision as of 10:53, 26 October 2008

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.

relbocletoc

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