System.SysUtils.FileOpen
Delphi
function FileOpen(const FileName: string; Mode: LongWord): THandle;
C++
extern DELPHI_PACKAGE NativeUInt __fastcall FileOpen(const System::UnicodeString FileName, unsigned Mode);
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.SysUtils.pas System.SysUtils.hpp |
System.SysUtils | System.SysUtils |
Description
Opens a specified file using a specified access mode.
Use FileOpen to open a file and obtain a file handle. The access mode value is constructed by or'ing one of the fmOpen constants with one of the fmShare constants defined in File open mode constants. If the return value is not INVALID_HANDLE_VALUE, the function was successful and the value is the file handle of the opened file. A return value of INVALID_HANDLE_VALUE indicates that an error has occurred.
The Mode parameter consists of an open mode and (possibly) a share mode or'ed together. The open mode must be one of the following values.
Value | Meaning |
---|---|
Open the file for reading only. | |
Open the file for writing only. Writing to the file completely replaces the current contents. | |
Open the file to modify the current contents rather than replace them. |
The share mode must be one of the following values.
Value | Meaning |
---|---|
Sharing is compatible with the way FCBs are opened. | |
Other applications cannot open the file for any reason. | |
Other applications can open the file for reading, but not for writing. | |
Other applications can open the file for writing, but not for reading. | |
No attempt is made to prevent other applications from reading from or writing to the file. |
Note: We do not encourage the use of the non-native Delphi language file handlers such as FileOpen. These routines map to system routines and return OS file handles, not normal Delphi file variables. These are low-level file access routines. For normal file operations use AssignFile, Rewrite, and Reset instead.