int _lopen(lpPathName,iReadWrite)
This function opens the file with the name specified by the lpPathName parameter. The iReadWrite parameter specifies the access mode of the file when the function opens it. When the function opens the file, the pointer is set to the beginning of the file.
Parameter | Type/Description |
lpPathName | LPSTR Points to a null-terminated character string that names the file to be opened. The string must consist of characters from the ANSI character set. | ||
iReadWrite | int Specifies whether the function is to open the file with read access, write access, or both. The parameter must be one of the following values: | ||
Value | Meaning | ||
OF_READ | Opens the file for reading only. | ||
OF_READWRITE | Opens the file for reading and writing. | ||
OF_SHARE_COMPAT | Opens the file with compatibility mode, allowing any process on a given machine to open the file any number of times. OpenFile fails if the file has been opened with any of the other sharing modes. | ||
Parameter | Type/Description |
Value | Meaning | |
OF_SHARE_DENY_NONE | Opens the file without denying other processes read or write access to the file. OpenFile 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. OpenFile 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. OpenFile fails if the file has been opened in compatibility or for write access by any other process. | |
OF_SHARE_EXCLUSIVE | Opens the file with exclusive mode, denying other processes both read and write access to the file. OpenFile fails if the file has been opened in any other mode for read or write access, even by the current process. | |
OF_WRITE | Opens the file for writing only. |
The return value specifies an MS-DOS file handle if the function opened the file. Otherwise, it is –1.