> hello to all,
>
>
> Is there a way under windows 2000 via perl to determine when a file is
> currently opened with text editor?
>
Peter Guzis posted code a while back that used Win32::SharedFileOpen +
flock. For reasons that are unclear to me, Win32::SharedFileOpen was not
being polite about cleaning up it's file handles, and if the code ran for
long periods of time (service) bad things started to happen. Using
Win32API::File::createFile instead seems to work fine (only been running
this code for a few days, so use at your own risk!). I would still really
like to find a fuser equivalent that would tell me the process/user that
has the file open ...
Steve
use Win32API::File;
# returns 1 if the file is open elsewhere, 0 if not
sub FileOpened {
my $file = shift;
my $fh;
if ($fh = Win32API::File::createFile( $file, 'r', '' ) ) {
Win32API::File::CloseHandle($fh);
return 0;
}
return 1;
}
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs