Hello,
If I delete a file in my application, of course, the file is gone.
But is there a possibility to delete file in a way that the deleted files can be restored from the trash?
Moving to $Recycle.Bin doesn't seem to be enough.
Thank you.
#include <stdio.h>
#include <windows.h>
#include <shellapi.h>
#define FO_DELETE 3 //Delete the files specified in pFrom.
#define FOF_ALLOWUNDO 0x40 //Preserve undo information, if possible.
#define FOF_NOCONFIRMATION 0x0010 //Do not ask the user to confirm selection.
typedef struct _SHFILEOPSTRUCT {
HWND hwnd;
UINT wFunc;
LPCSTR pFrom;
LPCSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;
int main()
{
SHFILEOPSTRUCT shf;
shf.wFunc = FO_DELETE;
shf.pFrom = "C:\\myfile.txt\0\0"; //File to delete
shf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION;
int result = SHFileOperation(&shf);
if (result == 0)
{
printf("File deleted successfully.\n");
}
else
{
printf("Error: %d\n", result);
}
return 0;
}
#define FO_DELETE 0x0003
#define FOF_ALLOWUNDO 0x0040
******************************************************************************
DeleteFile( DOCDOEL, ArcLst ) // DOCDOEL = file that has to be deleted
// ArcLst = Dialog Box
******************************************************************************
static function DeleteFile( cFileName , oDlg )
return SHFileOperation( oDlg:hWnd, FO_DELETE , cFileName + Chr( 0 ) ,, FOF_ALLOWUNDO )
Returns zero if successful; otherwise nonzero
If pFrom is set to a file name without a full path, deleting the file with FO_DELETE does not move it to the Recycle Bin, even if the FOF_ALLOWUNDO flag is set. You must provide a full path to delete the file to the Recycle Bin.
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 62 guests