共用方式為


_open_osfhandle

Associates a C run-time file handle with a existing operating-system file handle.

int_open_osfhandle(longosfhandle**,intflags);**

Routine Required Header Compatibility
_open_osfhandle <io.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

If successful, _open_osfhandle returns a C run-time file handle. Otherwise, it returns –1.

Parameters

osfhandle

Operating-system file handle

flags

Types of operations allowed

Remarks

The _open_osfhandle function allocates a C run-time file handle and sets it to point to the operating-system file handle specified by osfhandle. The flags argument is an integer expression formed from one or more of the manifest constants defined in FCNTL.H. When two or more manifest constants are used to form the flags argument, the constants are combined with the bitwise-OR operator ( | ).

The FCNTL.H file defines the following manifest constants:

_O_APPEND

Positions file pointer to end of file before every write operation.

_O_RDONLY

Opens file for reading only

_O_TEXT

Opens file in text (translated) mode

File Handling Routines