I am not sure if this is a good idea. If the deletion takes longer, there are timeouts which can strike.
I have never used the commands to prevent the shutdown. (MSDN)
Maybe it is easier to postpone the deletion until the next Windows startup?
Example : delete file at next Windows startup
Code: Select all
MoveFileEx_("Some_file_i_dont_need_anymore", 0, #MOVEFILE_DELAY_UNTIL_REBOOT)
MSDN: If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT and lpNewFileName is NULL, MoveFileEx registers the lpExistingFileName file to be deleted when the system restarts. If lpExistingFileName refers to a directory, the system removes the directory at restart only if the directory is empty.
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 11 Home