internal static void GetReference(System.IntPtr pRestrictedErrorInfo, out string errReference) { Debug.Assert(pRestrictedErrorInfo != IntPtr.Zero); IntPtr pReference = IntPtr.Zero; errReference = null; try { __com_IRestrictedErrorInfo *pComRestrictedErrorInfo = (__com_IRestrictedErrorInfo *)pRestrictedErrorInfo; int result = CalliIntrinsics.StdCall__int(pComRestrictedErrorInfo->pVtable->pfnGetReference, pRestrictedErrorInfo, out pReference); if (result >= 0) { errReference = Interop.COM.ConvertBSTRToString(pReference); } else { errReference = null; } } finally { if (pReference != IntPtr.Zero) { McgMarshal.SysFreeString(pReference); } } }
internal static bool GetErrorDetails(System.IntPtr pRestrictedErrorInfo, out string errMsg, out int hr, out string resErrMsg, out string errCapSid) { Debug.Assert(pRestrictedErrorInfo != IntPtr.Zero); IntPtr pErrDes, pResErrDes, pErrCapSid; pErrDes = pResErrDes = pErrCapSid = IntPtr.Zero; int result; try { // Get the errorDetails associated with the restrictedErrorInfo. __com_IRestrictedErrorInfo *pComRestrictedErrorInfo = (__com_IRestrictedErrorInfo *)pRestrictedErrorInfo; result = CalliIntrinsics.StdCall__int( pComRestrictedErrorInfo->pVtable->pfnGetErrorDetails, pRestrictedErrorInfo, out pErrDes, out hr, out pResErrDes, out pErrCapSid); if (result >= 0) { // RestrictedErrorInfo details can be used since the pRestrictedErrorInfo has the same hr value as the hr returned by the native code. errMsg = Interop.COM.ConvertBSTRToString(pErrDes); resErrMsg = Interop.COM.ConvertBSTRToString(pResErrDes); errCapSid = Interop.COM.ConvertBSTRToString(pErrCapSid); } else { errMsg = resErrMsg = errCapSid = null; hr = 0; } } finally { if (pErrDes != IntPtr.Zero) { McgMarshal.SysFreeString(pErrDes); } if (pResErrDes != IntPtr.Zero) { McgMarshal.SysFreeString(pResErrDes); } if (pErrCapSid != IntPtr.Zero) { McgMarshal.SysFreeString(pErrCapSid); } } return(result >= 0); }