AFAIK, there are only two ways if you need to do so in Vista or earlier versions of Windows:
1) Try to delete it every 5 minutes. If it can be deleted, it will be deleted.
2) Try adding a startup task in scheduler/registry, and delete the file at next boot time. Most likely it will not be locked.
Methods such as scanning the processes for opened file handles won't reliably work as your application have no guarantee that it is access to all system process... even when it's running as local administrator.
Please also read a blog post related here.
- Diedit oleh cheong00Editor 13 Maret 2012 9:50
I think either the process which has exclusively captured the file should inform other apps (for example by sending a signal using a kernel synchronization construct such as Mutex) or the waiting process should use a polling mechanism and periodically check to see if the file is freed or not.