Hi Mark,

I have had similar experiences with TFileStream and AssignFile etc.
The only way I have found to get sharing to work happily is to use the
Windows API file methods directly.
Windows.CreateFile() etc.
SysUtils.FileCreate() wraps the above function, but unfortunately doesn't
set any sharing flags, so defaults to exclusive access.

var 
FileHandle: integer;
FileName: string;

...
FileHandle := integer(Windows.CreateFile(PChar(FileName), GENERIC_READ,
FILE_SHARE_READ, nil, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0));

After this call, you can use the returned handle with the SysUtils
functions FileRead(), FileSeek(), FileClose().

Paul.

At 12:43 17/04/01 , you wrote:
>'allo - I was wondering how one would go about opening a file read-only and 
>shared?
>


----------------------------------------------------------
 Paul Spain,  Excellent Programming Company
 mailto:[EMAIL PROTECTED]
----------------------------------------------------------

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to