Skip to content

Latest commit

 

History

History
91 lines (82 loc) · 2.46 KB

get-osfhandle.md

File metadata and controls

91 lines (82 loc) · 2.46 KB
title ms.custom ms.date ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic apiname apilocation apitype f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager translation.priority.ht translation.priority.mt
_get_osfhandle | Microsoft Docs
11/04/2016
devlang-cpp
article
_get_osfhandle
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-stdio-l1-1-0.dll
DLLExport
get_osfhandle
_get_osfhandle
C++
operating systems, getting file handles
get_osfhandle function
_get_osfhandle function
file handles [C++], operating system
0bdd728a-4fd8-410b-8c9f-01a121135196
14
corob-msft
corob
ghogen
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
ru-ru
zh-cn
zh-tw
cs-cz
pl-pl
pt-br
tr-tr

_get_osfhandle

Retrieves the operating-system file handle that is associated with the specified file descriptor.

Syntax

intptr_t _get_osfhandle(   
   int fd   
);  

Parameters

fd
An existing file descriptor.

Return Value

An operating-system file handle if fd is valid. Otherwise, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, this function returns INVALID_HANDLE_VALUE (-1) and sets errno to EBADF, indicating an invalid file handle.

Remarks

To close a file opened with _get_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.

Requirements

Routine Required header
_get_osfhandle <io.h>

For more compatibility information, see Compatibility in the Introduction.

See Also

File Handling
_close
_creat, _wcreat
_dup, _dup2
_open, _wopen