You can use the delphi FileOpen function to carry out your checks. Pass it
an appropriate access mode and see what comes back. GetLastError will get
the Windows I/O error code if the function returns -1.
============================================
Patrick Dunford, Christchurch, NZ
http://patrick.dunford.com/
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Aaron Scott-Boddendijk
> Sent: Sunday, 1 August 1999 20:45
> To: Multiple recipients of list delphi
> Subject: Re: [DUG]: File Locking
>
>
> > I have a thorny problem.
> > I am wanting to open a file but before I do I need information
> about that
> file.
> >
> > I need to know the following:
> > Does anyone else have the file open?
> > Do they have that file opened exlusively?
> >
> > I need to be able to answer these two questions BEFORE I try to open the
> > file. In otherwords I can't try opening the file as a test of these
> > conditions.
> >
> > Any Ideas? I'm stumped.
>
> umm shouldn't you be able to do a
>
> try
> FS := TFileStream.Create(...);
> except
> // catch the exception if the file was already open
> end;
>
> Short of some API searching I'd guess the easiest way to identify if they
> have
> exclusive open is to try to open it with sharing. If you need to use the
> file exclusively
> then open with no file sharing.
>
> --
> Aaron@home
>
> ------------------------------------------------------------------
> ---------
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz