procedure OpenForShare(const FileName: String);
var
; FileHandle : Integer;
begin
; FileHandle := FileOpen(FileName, fmOpenWrite or fmShareDenyNone);
; if FileHandle > 0 then
; ; {valid file handle}
; else
; ; {Open error: FileHandle = negative DOS error code}
end;
const
; fmOpenRead ; ; ; = $0000;
; fmOpenWrite ; ; ;= $0001;
; fmOpenReadWrite ;= $0002;
; fmShareCompat ; ;= $0000;
; fmShareExclusive = $0010;
; fmShareDenyWrite = $0020;
; fmShareDenyRead ;= $0030;
; fmShareDenyNone ;= $0040;
Description
The file open mode constants are used when a file or stream is opened to control how it can be shared.
The TFileStream constructor has a Mode parameter that you can set to one of these constants:
Constant Definition
fmCreate If the file exists, open for write access, otherwise, create a new file. Unlike the other constants, which are declared in the SysUtils unit, this constant is declared in classes.pas.
fmOpenRead Open for read access only.
fmOpenWrite Open for write access only.
fmOpenReadWrite Open for read and write access.
fmShareCompat Compatible with the way FCBs are opened.
fmShareExclusive Read and write access is denied.
fmShareDenyWrite Write access is denied.
fmShareDenyRead Read access is denied.
fmShareDenyNone Allows full access for others.