After successfully deleting all files, the uninstaller tries to delete the remaining empty directories. The deletion algorithm is the search for paths of directories by recursion with FindFirstFile / FindNextFile and writing them to the vector of strings, after which deleting directories by paths from the end of the vector with error handling. When developing the application, the picture is as follows: 
It turns out that only the child empty directories are deleted, and as soon as the cycle reaches their parent, it responds with error 145 (the directory is not empty), although it is clear from the listing that all descendants have been deleted. And the root directory is generally occupied by another process (error 32). I repeat - all directories are pre-cleared of files. It turns out that the operation of deleting a directory is deferred and deletion takes place after the application is closed. When restarting the uninstaller, only the last empty folders are deleted again. Use in the right places CloseHandle and / or FlushFileBuffers did not produce any result. The question is how to get the uninstaller to delete directories instantly, without waiting for the application to close?
PS: the uninstaller works from another independent directory
FindCloseFileis called? - Anton ShchyrovFindClose()- Anton ShchyrovFindFirstFile/FindNextFilefor each error-free callFindFirstFileshould be a call toFindClose()- Anton Shchyrov