System.SysUtils.FileOpen
Delphi
function FileOpen(const FileName: string; Mode: LongWord): THandle;
C++
extern DELPHI_PACKAGE Winapi::Windows::THandle __fastcall FileOpen(const System::UnicodeString FileName, System::LongWord Mode);
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.SysUtils.pas System.SysUtils.hpp |
System.SysUtils | System.SysUtils |
Description
FileOpen opens a specified file using a specified access mode.
Use FileOpen to open a file and obtain a file handle. The Mode
parameter indicates how the file is opened. The Mode
parameter consists of an open mode and (possibly) a share mode or'ed together.
For open mode constants you must use one of the following values.
Value | Meaning |
---|---|
Automatically creates the file only if it does not exist, otherwise fails. | |
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. |
For share mode constants you must use 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. |
FileOpen can return:
- A different value from INVALID_HANDLE_VALUE, meaning that the function was successful and the value is the file handle of the opened file.
- A value equal to INVALID_HANDLE_VALUE, indicating that an error has occurred.