Ejemplo n.º 1
0
        internal static string GetMessage(int errorCode)
        {
            StringBuilder lpBuffer = new StringBuilder(0x200);

            if (NativePipe.FormatMessage(0x3200, NativePipe.NULL, errorCode, 0, lpBuffer, lpBuffer.Capacity, NativePipe.NULL) != 0)
            {
                return(lpBuffer.ToString());
            }
            return(string.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Remoting_UnknownError_Num"), new object[] { errorCode.ToString(CultureInfo.InvariantCulture) }));
        }
Ejemplo n.º 2
0
        // Gets an error message for a Win32 error code.
        internal static String GetMessage(int errorCode)
        {
            StringBuilder sb     = new StringBuilder(512);
            int           result = NativePipe.FormatMessage(NativePipe.FORMAT_MESSAGE_IGNORE_INSERTS |
                                                            NativePipe.FORMAT_MESSAGE_FROM_SYSTEM | NativePipe.FORMAT_MESSAGE_ARGUMENT_ARRAY,
                                                            NativePipe.NULL, errorCode, 0, sb, sb.Capacity, NativePipe.NULL);

            if (result != 0)
            {
                // result is the # of characters copied to the StringBuilder on NT,
                // but on Win9x, it appears to be the number of MBCS bytes.
                // Just give up and return the String as-is...
                String s = sb.ToString();
                return(s);
            }
            else
            {
                return(String.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Remoting_UnknownError_Num"), errorCode.ToString(CultureInfo.InvariantCulture)));
            }
        }