Silverfrost Forums

Welcome to our forums

Deleting files to the Recycle Bin

5 Sep 2004 5:59 #16

Summary

FTN95 does not currently provide a method for deleting files to the recycle bin.

Solution

The Windows API routine 'SHFileOperation' can be used to delete files to the recycle bin.

This routine takes a structure as it's only argument which contains all the information on which file(s) to delete and whether to display a dialog box etc. An example of using this routine follows:

program recycle_bin_test
include <windows.ins>

type shFileOpStruct
sequence
integer*4 :: hWnd = 0
integer*4 :: wFunc = 0
integer*4 :: pFrom = 0
integer*4 :: pTo = 0
integer*2 :: fFlags = 0
integer*4 :: fAnyOperationsAborted = 0
integer*4 :: hNameMappings = 0
integer*4 :: lpszProgressTitle = 0
end type

integer, parameter :: FO_DELETE = 3
integer, parameter :: FOF_ALLOWUNDO = 64

type(shFileOpStruct) op
character*1024 opFilename
integer opResult

op%wFunc = FO_DELETE
opFilename = 'tempfile.txt'//char(0)//char(0)
op%pFrom = loc(opFilename)
op%fFlags = FOF_ALLOWUNDO
opResult = SHFileOperation(op)
end

For more information on this routine please see Microsoft's documentation at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shfileoperation.asp


-- Admin Silverfrost Limited
This forum is locked.