Show: Object Pascal C++
Display Preferences

System.SysUtils.FileOpen

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

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

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 Object Pascal language file handlers such as FileOpen. These routines map to system routines and return OS file handles, not normal Object Pascal 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
Translations