INF: Windows OpenFile Function vs. C Run-Time "open" Functions

ID Number: Q11988

2.00 2.03 2.10 3.00 3.10

WINDOWS

Summary:

In Windows, the OpenFile function creates an MS-DOS file handle

through which an application can access Windows-specific files.

OpenFile initially opens the file in binary raw mode by performing an

MS-DOS Interrupt 21h Function 3Dh. If the lpFileName parameter

specifies only a filename and an extension, OpenFile searches for a

matching file in the following directories:

- The current directory.

- The Windows directory. The GetWindowsDirectory function returns the

path to this directory.

- The Windows system directory . The GetSystemDirectory function

returns the path to this directory.

- The directories listed in the PATH environment variable.

The open, fopen, and sopen functions provided by the Microsoft C run-

time libraries and the _lopen function provided by Windows can be used

to access any file. The open functions do not necessarily open a file

in binary raw mode; the application is required to set the binary

attribute explicitly. The OpenFile function automatically performs

this step.

If the filename parameter specifies only a filename and extension,

the open functions search for a matching file only in the current

directory.

An application should use the OpenFile function any time an MS-DOS

file handle is required.

Additional reference words: 2.x TAR56861