I need a programmatic way to know if a directory (as opposed to a file) is in use, for example because it is open on explorer or a CMD prompt. If the directory is in use, then it cannot be deleted. The current way I have found to do that is trying to rename it, is there a less intrusive way to do this under Windows?
Share
You didn’t secify a language, so I am assumming c++. You can try to lock the file yourself using LockFile or LockFileEx, if it returns zero another process has the file locked already.
You can’t unlock a lock if another process has it locked without terminating the process.