Skip to content
⌘ NSIS Forum Archive

Recycle rather than delete?

9 posts

Marshall7a#

Recycle rather than delete?

The Delete command permanently deletes files. How would I go about having files on the end users' computer moved to their recycle bin instead?
iceman_k#
You can call the SHFileOperationA Windows API function using the System plugin. You will need to create the SHFILEOPSTRUCT structure with the FO_DELETE flag before calling the function.
Marshall7a#
Am I gonna get flamed for saying that I didn't understand a single word of what you just said?
Joost Verburg#
It's not as difficult as you think. An API is a Windows function that can be called from a Windows application. You can call these APIs from an NSIS installer using the System plug-in.

A detailed description of all APIs is available at http://msdn.microsoft.com/library
RobGrant#
This is just a programming question, but I haven't found an obvious answer to it so far and I'm curious:

I can understand you Exch $R0 to get the pathname of the file to be recycled into variable $R0, but why then do you Push $R1 and $R2 onto the stack? What do they hold when you push them on? Because you pull $R1 off almost instantly as a value - what's changed it?

Just want to understand a bit more 🙂

Thanks

Rob
Joost Verburg#
That's only the restore the original value of the variable after calling the function.