Exemplo n.º 1
0
        internal static string GetErrorMessage(int errorCode, bool hresult)
        {
            uint temp = (uint)errorCode;

            if (!hresult)
            {
                temp = ((((temp) & 0x0000FFFF) | (7 << 16) | 0x80000000));
            }
            string        errorMsg = "";
            StringBuilder sb       = new StringBuilder(256);
            int           result   = UnsafeNativeMethods.FormatMessageW(UnsafeNativeMethods.FORMAT_MESSAGE_IGNORE_INSERTS |
                                                                        UnsafeNativeMethods.FORMAT_MESSAGE_FROM_SYSTEM |
                                                                        UnsafeNativeMethods.FORMAT_MESSAGE_ARGUMENT_ARRAY,
                                                                        0, (int)temp, 0, sb, sb.Capacity + 1, 0);

            if (result != 0)
            {
                errorMsg = sb.ToString(0, result);
            }
            else
            {
                errorMsg = String.Format(CultureInfo.CurrentCulture, SR.DSUnknown, Convert.ToString(temp, 16));
            }

            return(errorMsg);
        }
Exemplo n.º 2
0
        internal static string GetErrorMessage(int errorCode, bool hresult)
        {
            uint num = (uint)errorCode;

            if (!hresult)
            {
                num = ((num & 0xffff) | 0x70000) | 0x80000000;
            }
            StringBuilder lpBuffer = new StringBuilder(0x100);
            int           length   = UnsafeNativeMethods.FormatMessageW(0x3200, 0, (int)num, 0, lpBuffer, lpBuffer.Capacity + 1, 0);

            if (length != 0)
            {
                return(lpBuffer.ToString(0, length));
            }
            return(Res.GetString("DSUnknown", new object[] { Convert.ToString((long)num, 0x10) }));
        }
Exemplo n.º 3
0
        internal static string GetErrorMessage(int errorCode, bool hresult)
        {
            string str;
            int    num = errorCode;

            if (!hresult)
            {
                num = num & 0xffff | 0x70000 | -2147483648;
            }
            StringBuilder stringBuilder = new StringBuilder(0x100);
            int           num1          = UnsafeNativeMethods.FormatMessageW(0x3200, 0, num, 0, stringBuilder, stringBuilder.Capacity + 1, 0);

            if (num1 == 0)
            {
                object[] objArray = new object[1];
                objArray[0] = Convert.ToString((long)num, 16);
                str         = Res.GetString("DSUnknown", objArray);
            }
            else
            {
                str = stringBuilder.ToString(0, num1);
            }
            return(str);
        }