Beispiel #1
0
        private static string GetMessage(ManagementStatus errorCode)
        {
            string str = null;
            IWbemStatusCodeText wbemStatusCodeText = (IWbemStatusCodeText)(new WbemStatusCodeText());

            if (wbemStatusCodeText != null)
            {
                try
                {
                    int errorCodeText_ = wbemStatusCodeText.GetErrorCodeText_((int)errorCode, 0, 1, out str);
                    if (errorCodeText_ != 0)
                    {
                        errorCodeText_ = wbemStatusCodeText.GetErrorCodeText_((int)errorCode, 0, 0, out str);
                    }
                }
                catch
                {
                }
            }
            return(str);
        }
        private static string GetMessage(ManagementStatus errorCode)
        {
            string messageText       = null;
            IWbemStatusCodeText text = null;

            text = (IWbemStatusCodeText) new WbemStatusCodeText();
            if (text != null)
            {
                try
                {
                    if (text.GetErrorCodeText_((int)errorCode, 0, 1, out messageText) != 0)
                    {
                        int num = text.GetErrorCodeText_((int)errorCode, 0, 0, out messageText);
                    }
                }
                catch
                {
                }
            }
            return(messageText);
        }
        private static string GetMessage(ManagementStatus errorCode)
        {
            string msg = null;
            IWbemStatusCodeText statusCode = null;
            int hr;

            statusCode = (IWbemStatusCodeText) new WbemStatusCodeText();
            if (statusCode != null)
            {
                try {
                    hr = statusCode.GetErrorCodeText_((int)errorCode, 0, 1, out msg);

                    // Just in case it didn't like the flag=1, try it again
                    // with flag=0.
                    if (hr != 0)
                    {
                        hr = statusCode.GetErrorCodeText_((int)errorCode, 0, 0, out msg);
                    }
                }
                catch {}
            }

            return(msg);
        }