_lopen

  HFILE _lopen(lpszFileName, fnOpenMode)    
  LPCSTR lpszFileName; /* file name */
  int fnOpenMode; /* file access */

The _lopen function opens an existing file and sets the file pointer to the beginning of the file.

Parameters

lpszFileName

Points to a null-terminated string that names the file to be opened. The string must consist of characters from the Windows character set.

fnOpenMode

Specifies the modes in which to open the file. This parameter consists of one access mode and an optional share mode.

Value Access mode

OF_READ  
  Opens the file for reading only.
OF_READWRITE  
  Opens the file for reading and writing.
OF_WRITE  
  Opens the file for writing only.

Value Share mode (optional)

OF_SHARE_COMPAT  
  Opens the file in compatibility mode, allowing any process on a given machine to open the file any number of times. _lopen fails if the file has been opened by using any of the other sharing modes.
OF_SHARE_DENY_NONE  
  Opens the file without denying other processes read or write access to the file. _lopen fails if the file has been opened in compatibility mode by any other process.
OF_SHARE_DENY_READ  
  Opens the file and denies other processes read access to the file. _lopen fails if the file has been opened in compatibility mode or for read access by any other process.
OF_SHARE_DENY_WRITE  
  Opens the file and denies other processes write access to the file. _lopen fails if the file has been opened in compatibility mode or for write access by any other process.
OF_SHARE_EXCLUSIVE  
  Opens the file in exclusive mode, denying other processes both read and write access to the file. _lopen fails if the file has been opened in any other mode for read or write access, even by the current process.

Return Value

The return value is a file handle if the function is successful. Otherwise, it is -1.

Comments

This function is maintained for compatibility with previous versions of Windows. Win32 applications should use the CreateFile function to open a file.

See Also

CreateFile