How to cancel a pending MoveFileEx operation?

I use the following command to delete some files after rebooting the computer:

MoveFileEx(PChar(File_Address), Nil, MOVEFILE_DELAY_UNTIL_REBOOT);

How can I cancel this command and prevent files from being deleted after a reboot?

+5
source share
2 answers

Files queued for deletion are placed in the registry under HKLM\System\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations. Perhaps you can delete entries from there to prevent file deletion. I could not find an API function for this.

+13
source

I think you could copy the file (since it has not been deleted yet) and then use

MoveFileEx(copy_of_file, original_file, MOVEFILE_DELAY_UNTIL_REBOOT)

to put it back in place during a reboot.

, .

0

All Articles