Don't KILL files-to-delete anymore, but send them to the Recycle Bin, in the way Windows Explorer itself does.
This example code sends a file MYFILE.TXT from the root directory to the bin.
This example code sends a file MYFILE.TXT from the root directory to the bin.
Code:
#COMPILE EXE #INCLUDE "WIN32API.INC" FUNCTION RecycleBin(FilNam AS STRING) AS LONG LOCAL shfo AS SHFILEOPSTRUCT ' predefined structure LOCAL szSource AS ASCIIZ * 64 szSource = FilNam + CHR$(0) ' convert to ASCIIZ shfo.wFunc = %FO_DELETE ' function delete file shfo.pFrom = VARPTR(szSource) ' pointer to file shfo.fFlags = %FOF_ALLOWUNDO ' enable undo dummy& = SHFileOperation(shfo) ' call funtion FUNCTION = shfo.fAnyOperationsAborted ' return value, either 0 or non-zero END FUNCTION FUNCTION PBMAIN() LOCAL RetVal AS LONG RetVal = RecycleBin("C:\MYFILE.TXT") ' use the following lines only when the deleted file is part of an array or in a listbox IF RetVal = 0 THEN ARRAY DELETE StringArray(index) LISTBOX DELETE hDlg, %IDLISTBOX, position& END IF END FUNCTION
Comment