Associates a C run-time file descriptor with an existing operating-system file handle.
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 ( | ).
Fcntl.h defines the following manifest constants.
To close a file opened with _open_osfhandle, call _close. The underlying handle is also closed by a call to _close, so it is not necessary to call the Win32 function CloseHandle on the original handle.