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,
                                                                        IntPtr.Zero, (int)temp, 0, sb, sb.Capacity + 1, IntPtr.Zero);

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

            return(errorMsg);
        }
Exemplo n.º 2
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, IntPtr.Zero, num, 0, stringBuilder, stringBuilder.Capacity + 1, IntPtr.Zero);

            if (num1 == 0)
            {
                str = string.Concat(StringResources.DSUnknown, Convert.ToString((ulong)num, 16));
            }
            else
            {
                str = stringBuilder.ToString(0, num1);
            }
            return(str);
        }