开发者

How to cancel deferred MoveFileEx operation?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜