示例#1
0
        /// <summary>
        /// Returns runtime class name for a specific WinRT interface
        /// </summary>
        internal static string GetRuntimeClassName(IntPtr pWinRTItf)
        {
#if  ENABLE_MIN_WINRT
            void *unsafe_hstring = null;

            try
            {
                int hr = CalliIntrinsics.StdCall__int(
                    ((__com_IInspectable *)(void *)pWinRTItf)->pVtable->pfnGetRuntimeClassName,
                    pWinRTItf, &unsafe_hstring);

                // Don't throw if the call fails
                if (hr < 0)
                {
                    return(String.Empty);
                }

                return(McgMarshal.HStringToString(new IntPtr(unsafe_hstring)));
            }
            finally
            {
                if (unsafe_hstring != null)
                {
                    McgMarshal.FreeHString(new IntPtr(unsafe_hstring));
                }
            }
#else
            throw new PlatformNotSupportedException("GetRuntimeClassName(IntPtr)");
#endif
        }