Skip to content

Latest commit

 

History

History
87 lines (70 loc) · 2.21 KB

nf-winerror-hresult_from_win32.md

File metadata and controls

87 lines (70 loc) · 2.21 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:winerror.HRESULT_FROM_WIN32
HRESULT_FROM_WIN32 macro (winerror.h)
Maps a system error code to an HRESULT value.
HRESULT_FROM_WIN32
HRESULT_FROM_WIN32 macro [COM]
_com_HRESULT_FROM_WIN32
com.hresult_from_win32
com.hresult_from_win32_macro
winerror/HRESULT_FROM_WIN32
com\hresult_from_win32_macro.htm
com
40e6f80d-a778-4d5f-bb1b-db294815f8b5
12/05/2018
HRESULT_FROM_WIN32, HRESULT_FROM_WIN32 macro [COM], _com_HRESULT_FROM_WIN32, com.hresult_from_win32, com.hresult_from_win32_macro, winerror/HRESULT_FROM_WIN32
winerror.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
Windows
19H1
HRESULT_FROM_WIN32
winerror/HRESULT_FROM_WIN32
c++
APIRef
kbSyntax
HeaderDef
Winerror.h
HRESULT_FROM_WIN32

HRESULT_FROM_WIN32 macro

-description

Maps a system error code to an HRESULT value.

-parameters

-param x

The system error code.

-remarks

This macro is defined as follows:

//
// HRESULT_FROM_WIN32(x) used to be a macro, however we now run it as an inline function
// to prevent double evaluation of 'x'. If you still need the macro, you can use __HRESULT_FROM_WIN32(x)
//
#define __HRESULT_FROM_WIN32(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000)))

#ifndef __midl
FORCEINLINE HRESULT HRESULT_FROM_WIN32(unsigned long x) { 
   return (HRESULT)(x) <= 0 ? (HRESULT)(x) : (HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000);
}
#else
#define HRESULT_FROM_WIN32(x) __HRESULT_FROM_WIN32(x)
#endif

-see-also

Error Handling