Interop.HRESULT_FROM_WIN32 C# (CSharp) Method

HRESULT_FROM_WIN32() private method

private HRESULT_FROM_WIN32 ( int errorCode ) : int
errorCode int
return int
    internal static int HRESULT_FROM_WIN32(int errorCode)
    {
        if ((errorCode & 0x80000000) == 0x80000000)
        {
            return errorCode;
        }

        return (errorCode & 0x0000FFFF) | unchecked((int)0x80070000);
    } 
}

Usage Example

Beispiel #1
0
        public static int ConvertErrorCodeToHR(int error)
        {
            // This method allows common error detection code to be used by consumers
            // of HttpClient. This method converts the ErrorCode returned by WinHTTP
            // to the same HRESULT value as is provided in the .Net Native implementation
            // of HttpClient under the same error conditions. Clients would access
            // HttpRequestException.InnerException.HRESULT to discover what caused
            // the exception.
            switch ((uint)error)
            {
            case Interop.WinHttp.ERROR_WINHTTP_CONNECTION_ERROR:
                return(unchecked ((int)Interop.WinHttp.WININET_E_CONNECTION_RESET));

            default:
                // Marshal.GetHRForLastWin32Error can't be used as not all error codes originate from native
                // code.
                return(Interop.HRESULT_FROM_WIN32(error));
            }
        }
All Usage Examples Of Interop::HRESULT_FROM_WIN32