I use the below command to delete some files after reboot the machine:
MoveFileEx(PChar(File_Address), Nil, MOVEFILE_DELAY_UNTIL_REBOOT);
How can i cancel execution of this command and prevent files from deleting after reboot?
I use the below command to delete some files after reboot the machine:
MoveFileEx(PChar(File_Address), Nil, MOVEFILE_DELAY_UNTIL_REBOOT);
How can i cancel execution of this command and prevent files from deleting after reboot?
Files you enqueue for deletion this way are placed in the registry under HKLM\System\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations
. Perhaps you can delete entries from there, to prevent the files from being deleted. I couldn't find an API function for this.
I guess you could copy the file (since it hasn't been deleted yet) and then use
MoveFileEx(copy_of_file, original_file, MOVEFILE_DELAY_UNTIL_REBOOT)
to put it back in place during the reboot.
As Ken White has pointed out, though, it would be much much better to avoid this situation in the first place.
© 2022 - 2024 — McMap. All rights reserved.
MoveFileEx
to delete the file in the first place until you're absolutely sure you want to delete it. – Sato