开发者

How to cancel deferred MoveFileEx operation?

开发者 https://www.devze.com 2023-04-13 10:08 出处:网络
I use the below command to 开发者_开发百科delete some files after reboot the machine: MoveFileEx(PChar(File_Address), Nil, MOVEFILE_DELAY_UNTIL_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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号