예제 #1
0
        private static int LastCallError()
        {
            IErrorInfo errInfo = null;
            string     sDesc   = null;
            int        res;

            if (GetErrorInfo(0, out errInfo) < 0 || errInfo == null)
            {
                return(-1);
            }
            try
            {
                if (errInfo.GetDescription(out sDesc) < 0 || sDesc == null)
                {
                    return(-1);
                }
            }
            catch (System.Exception ex)
            {
                return(-2);
            }
            if (Int32.TryParse(sDesc, out res) == false)
            {
                return(-3);
            }
            return(res);
        }
예제 #2
0
        public ErrorInfo(IErrorInfo info)
        {
            string description, helpFile, source;
            try
            {
                info.GetDescription(out description);
                //info.GetGUID(out guid);
                info.GetHelpFile(out helpFile);
                info.GetDescription(out source);

                Description = description;
                HelpFile = helpFile;
                Source = source;
            }
            catch (Exception)
            {
                Description = "Couldn't get error info, operation still in progress";
            }
        }
예제 #3
0
 private void ProcessResult(int result)
 {
     if (result != 0)
     {
         IErrorInfo ppIErrorInfo     = null;
         int        res              = NativeMethods.GetErrorInfo(0, out ppIErrorInfo);
         string     pBstrDescription = string.Empty;
         if (ppIErrorInfo != null)
         {
             int res2 = ppIErrorInfo.GetDescription(out pBstrDescription);
         }
         string message = string.Format(CultureInfo.CurrentCulture, "Method returned an error. HRESULT = 0x{0:X8}", new object[] { result });
         if (!String.IsNullOrEmpty(pBstrDescription))
         {
             message = message + " : " + pBstrDescription;
         }
         throw new Exception(message);
     }
 }