Show: Delphi C++
Display Preferences

System.SysUtils.FileOpen

From XE2 API Documentation
Jump to: navigation, search

Delphi

function FileOpen(const FileName: string; Mode: LongWord): THandle;

C++

extern PACKAGE unsigned __fastcall FileOpen(const System::UnicodeString FileName, unsigned Mode);

Contents

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 0 or greater, the function was successful and the value is the file handle of the opened file. A return value of -1 indicates that an error 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

fmOpenRead

Open the file for reading only.

fmOpenWrite

Open the file for writing only. Writing to the file completely replaces the current contents.

fmOpenReadWrite

Open the file to modify the current contents rather than replace them.



The share mode must be one of the following values.



Value Meaning

fmShareCompat

Sharing is compatible with the way FCBs are opened.

fmShareExclusive

Other applications cannot open the file for any reason.

fmShareDenyWrite

Other applications can open the file for reading, but not for writing.

fmShareDenyRead

Other applications can open the file for writing, but not for reading.

fmShareDenyNone

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.

See Also

Code Examples

Personal tools
Previous Versions
Translations