This documentation is archived and is not being maintained.


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

int _open_osfhandle (
   intptr_t osfhandle,
   int flags 


Operating-system file handle.
Types of operations allowed.

Return Value

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


The _open_osfhandle function allocates a C run-time file descriptor and associates it with 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:

Positions file pointer to end of file before every write operation.
Opens file for reading only.
Opens file in text (translated) mode.


Routine Required header Compatibility
_open_osfhandle <io.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.

See Also

File Handling Routines | Run-Time Routines and .NET Framework Equivalents