http://qs321.pair.com?node_id=288261


in reply to win32-files in use by other processes ?

If the file has been opened by a non-perl process using the native OpenFile or CreateFile APIs, then the easiest (only?) way is to attempt to open the file using the native API OpenFile() with a uStyle parameter of OF_SHARE_EXCLUSIVE. If the file is already open, you will get an error.

If the file has been opened using Perl, then you will always be able to open it as perl use OF_SHARED_DENY_NONE which is fits with the unix standard. See flock for how Perl and unix prevent multiple accesses to files.

You can gain access to the native APIs via Win32::API (and Win32::API::Prototype) or via tyes Win32API::File


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.