示例#1
0
        private IWMWriterAdvanced GetWriterAdvanced(IBaseFilter asfWriter)
        {
            int hr;
            IWMWriterAdvanced pWriterAdvanced = null;

            // I don't understand why we can't just QueryInterface for a IWMWriterAdvanced, but
            // we just can't.  So, we use an IServiceProvider
            DirectShowLib.IServiceProvider pProvider = asfWriter as DirectShowLib.IServiceProvider;

            if (pProvider != null)
            {
                object opro;

                hr = pProvider.QueryService(typeof(IWMWriterAdvanced2).GUID, typeof(IWMWriterAdvanced2).GUID, out opro);
                WMError.ThrowExceptionForHR(hr);

                pWriterAdvanced = opro as IWMWriterAdvanced;
                if (pWriterAdvanced == null)
                {
                    throw new Exception("Can't get IWMWriterAdvanced");
                }
            }

            return(pWriterAdvanced);
        }
示例#2
0
        public void OnStatus(Status iStatus, int hr, AttrDataType dwType, IntPtr pValue, IntPtr pvContext)
        {
            Debug.Write(string.Format("{0} 0x{1:x} {2} {3} {4} {5} ", iStatus, hr, WMError.GetErrorText(hr), dwType, pValue.ToInt32(), pvContext.ToInt32()));

            if ((iStatus == Status.Timer) && (dwType == AttrDataType.DWORD) && (Marshal.ReadInt32(pValue) == m_CheckTimer) && (pvContext.ToInt32() == 345))
            {
                m_Triggered = true;
            }

            switch (dwType)
            {
            case AttrDataType.STRING:
                Debug.WriteLine(Marshal.PtrToStringUni(pValue));
                break;

            case AttrDataType.WORD:
                Debug.WriteLine(Marshal.ReadInt16(pValue));
                break;

            case AttrDataType.DWORD:
            case AttrDataType.BOOL:
                Debug.WriteLine(Marshal.ReadInt32(pValue));
                break;

            case AttrDataType.QWORD:
                Debug.WriteLine(Marshal.ReadInt64(pValue));
                break;

            default:
                Debug.WriteLine("???");
                break;
            }
        }
        void IWMStatusCallback.OnStatus(Status iStatus, int hr, AttrDataType dwType, IntPtr pValue, IntPtr pvContext)
        {
            m_LastResult = hr;

            Debug.Write(string.Format("{0} 0x{1:x} {2} {3} {4} {5} ", iStatus, hr, WMError.GetErrorText(hr), dwType, pValue.ToInt32(), pvContext.ToInt32()));

            switch (dwType)
            {
            case AttrDataType.STRING:
                Debug.WriteLine(Marshal.PtrToStringUni(pValue));
                break;

            case AttrDataType.WORD:
                Debug.WriteLine(Marshal.ReadInt16(pValue));
                break;

            case AttrDataType.DWORD:
            case AttrDataType.BOOL:
                Debug.WriteLine(Marshal.ReadInt32(pValue));
                break;

            case AttrDataType.QWORD:
                Debug.WriteLine(Marshal.ReadInt64(pValue));
                break;

            default:
                Debug.WriteLine("???");
                break;
            }
        }
        public void OnStatus(Status iStatus, int hr, AttrDataType dwType, IntPtr pValue, IntPtr pvContext)
        {
            if (hr != 0)
            {
                string s = WMError.GetErrorText(hr);
            }

            if (iStatus == Status.Opened || iStatus == Status.BufferingStart)
            {
                lock (m_openLock)
                {
                    Monitor.PulseAll(m_openLock);
                }
            }
        }
示例#5
0
        private void TestProxy()
        {
            string s;
            bool   b;
            int    i;
            int    c = 0;

            int hr = m_ian.FindProxyForURL("http", "limegreensocks.com", out b, out s, out i, ref c);

            WMError.ThrowExceptionForHR(hr);

            Debug.Assert(b == false);

            m_ian.RegisterProxyFailure(-1, c);
            m_ian.ShutdownProxyContext(c);
        }
示例#6
0
        private void ShowError(Exception e)
        {
            int    hr = Marshal.GetHRForException(e);
            string s  = WMError.GetErrorText(hr);

            if (s == null)
            {
                s = e.Message;
            }
            else
            {
                s = string.Format("{0} ({1})", s, e.Message);
            }

            System.Windows.Forms.MessageBox.Show(string.Format("0x{0:x}: {1}", hr, s), "Exception", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
        }
示例#7
0
        /// <summary>
        /// Retrieve the url that should be connected to from media player.  From withing
        /// media player user File/Open URL and entry the string returned from this function.
        /// </summary>
        /// <returns></returns>
        public string GetURL()
        {
            int hr;
            int iSize = 0;

            // Call the function once to get the size
            hr = m_pNetSink.GetHostURL(null, ref iSize);
            WMError.ThrowExceptionForHR(hr);

            StringBuilder sRet = new StringBuilder(iSize, iSize);

            hr = m_pNetSink.GetHostURL(sRet, ref iSize);
            WMError.ThrowExceptionForHR(hr);

            // Trim off the trailing null
            return(sRet.ToString().Substring(0, iSize - 1));
        }
示例#8
0
        /// <summary>
        /// Get and configure the IWMWriterAdvanced
        /// </summary>
        /// <param name="asfWriter">IBaseFilter from which to get the IWMWriterAdvanced</param>
        void DoAnet(IBaseFilter asfWriter)
        {
            int hr;
            int dwPortNum = PortNum;

            // Get the IWMWriterAdvanced
            IWMWriterAdvanced pWriterAdvanced = GetWriterAdvanced(asfWriter);

            try
            {
                // Remove all the sinks from the writer
                RemoveAllSinks(pWriterAdvanced);

                // Say we are using live data
                hr = pWriterAdvanced.SetLiveSource(true);
                WMError.ThrowExceptionForHR(hr);

                // Create a network sink
                hr = WMUtils.WMCreateWriterNetworkSink(out m_pNetSink);
                WMError.ThrowExceptionForHR(hr);

                // Configure the network sink
                hr = m_pNetSink.SetNetworkProtocol(NetProtocol.HTTP);
                WMError.ThrowExceptionForHR(hr);

                // Configure the network sink
                hr = m_pNetSink.SetMaximumClients(MaxClients);
                WMError.ThrowExceptionForHR(hr);

                // Done configuring the network sink, open it
                hr = m_pNetSink.Open(ref dwPortNum);
                WMError.ThrowExceptionForHR(hr);

                // Add the network sink to the IWMWriterAdvanced
                hr = pWriterAdvanced.AddSink(m_pNetSink as IWMWriterSink);
                WMError.ThrowExceptionForHR(hr);
            }
            finally
            {
                if (pWriterAdvanced != null)
                {
                    Marshal.ReleaseComObject(pWriterAdvanced);
                    pWriterAdvanced = null;
                }
            }
        }
示例#9
0
        private void RemoveAllSinks(IWMWriterAdvanced pWriterAdvanced)
        {
            IWMWriterSink ppSink;
            int           iSinkCount;

            int hr = pWriterAdvanced.GetSinkCount(out iSinkCount);

            WMError.ThrowExceptionForHR(hr);

            for (int x = iSinkCount - 1; x >= 0; x--)
            {
                hr = pWriterAdvanced.GetSink(x, out ppSink);
                WMError.ThrowExceptionForHR(hr);

                hr = pWriterAdvanced.RemoveSink(ppSink);
                WMError.ThrowExceptionForHR(hr);
            }
        }
        private void Test()
        {
            string pName, pw;
            bool   b;
            NetSourceURLCredPolicySettings ps;

            m_ian.SetCredentialsEx2("foo", "bar", false, "david", "moo", true, false, true);
            m_ian.GetCredentialsEx2("foo", "bar", false, true, out ps, out pName, out pw, out b);

            Debug.Assert(pName == "david" && pw == "moo" && b == false);

            string s;
            long   context = 0;
            int    p;
            int    hr = m_ian.FindProxyForURLEx2("http", "www.limegreensocks.com", "http://www.limegreensocks.com/DShow", out b, out s, out p, ref context);

            WMError.ThrowExceptionForHR(hr);

            m_ian.ShutdownProxyContext2(context);
        }
示例#11
0
        /// <summary>
        /// Queries the WM ASF Writer filter for the IWMWriterAdvanced interface.
        /// </summary>
        /// <returns>the IWMWriterAdvanced interface from the ASF Writer filter</returns>
        protected IWMWriterAdvanced GetWriterAdvanced()
        {
            int hr;
            IWMWriterAdvanced pWriterAdvanced = null;

            DirectShowLib.IServiceProvider pProvider = _asfFilter as DirectShowLib.IServiceProvider;

            if (pProvider != null)
            {
                object opro;

                hr = pProvider.QueryService(typeof(IWMWriterAdvanced2).GUID, typeof(IWMWriterAdvanced2).GUID, out opro);
                WMError.ThrowExceptionForHR(hr);

                pWriterAdvanced = opro as IWMWriterAdvanced;
                if (pWriterAdvanced == null)
                {
                    throw new Exception("Can't get IWMWriterAdvanced");
                }
            }

            return(pWriterAdvanced);
        }
示例#12
0
        public void OnStatus(Status iStatus, int hr, AttrDataType dwType, IntPtr pValue, IntPtr pvContext)
        {
            Debug.Write(string.Format("Status: {0} 0x{1:x} {2} {3} {4} {5} ", iStatus, hr, WMError.GetErrorText(hr), dwType, pValue.ToInt32(), pvContext.ToInt32()));

            if (iStatus == Status.Opened)
            {
                m_Opened = true;
            }

            switch (dwType)
            {
            case AttrDataType.STRING:
                Debug.WriteLine(Marshal.PtrToStringUni(pValue));
                break;

            case AttrDataType.WORD:
                Debug.WriteLine(Marshal.ReadInt16(pValue));
                break;

            case AttrDataType.DWORD:
            case AttrDataType.BOOL:
                int i = Marshal.ReadInt32(pValue);
                Debug.WriteLine(i);
                break;

            case AttrDataType.QWORD:
                Debug.WriteLine(Marshal.ReadInt64(pValue));
                break;

            default:
                Debug.WriteLine("???");
                break;
            }
        }
示例#13
0
        static void Main(string[] args)
        {
            try
            {
                //INSNetSourceCreatorTest t1 = new INSNetSourceCreatorTest();
                //t1.DoTests();

                //INSSBufferTest t2 = new INSSBufferTest();
                //t2.DoTests();

                //INSSBuffer2Test t3 = new INSSBuffer2Test();
                //t3.DoTests();

                //INSSBuffer3Test t4 = new INSSBuffer3Test();
                //t4.DoTests();

                //INSSBuffer4Test t5 = new INSSBuffer4Test();
                //t5.DoTests();

                //IWMAddressAccessTest t7 = new IWMAddressAccessTest();
                //t7.DoTests();

                //IWMAddressAccess2Test t8 = new IWMAddressAccess2Test();
                //t8.DoTests();

                //IWMBackupRestorePropsTest t9 = new IWMBackupRestorePropsTest();
                //t9.DoTests();

                //IWMBandwidthSharingTest t10 = new IWMBandwidthSharingTest();
                //t10.DoTests();

                //IWMClientConnectionsTest t11 = new IWMClientConnectionsTest();
                //t11.DoTests();

                //IWMClientConnections2Test t12 = new IWMClientConnections2Test();
                //t12.DoTests();

                //IWMCodecAMVideoAcceleratorTest t13 = new IWMCodecAMVideoAcceleratorTest();
                //t13.DoTests();

                //IWMCodecInfoTest t14 = new IWMCodecInfoTest();
                //t14.DoTests();

                //IWMCodecInfo2Test t15 = new IWMCodecInfo2Test();
                //t15.DoTests();

                //IWMCodecInfo3Test t16 = new IWMCodecInfo3Test();
                //t16.DoTests();

                //IWMCodecVideoAcceleratorTest t17 = new IWMCodecVideoAcceleratorTest();
                //t17.DoTests();

                //IWMCredentialCallbackTest t18 = new IWMCredentialCallbackTest();
                //t18.DoTests();

                //IWMDRMEditorTest t19 = new IWMDRMEditorTest();
                //t19.DoTests();

                //IWMDRMReaderTest t20 = new IWMDRMReaderTest();
                //t20.DoTests();

                //IWMDRMWriterTest t21 = new IWMDRMWriterTest();
                //t21.DoTests();

                //IWMHeaderInfoTest t22 = new IWMHeaderInfoTest();
                //t22.DoTests();

                //IWMHeaderInfo2Test t23 = new IWMHeaderInfo2Test();
                //t23.DoTests();

                //IWMHeaderInfo3Test t24 = new IWMHeaderInfo3Test();
                //t24.DoTests();

                //IWMImageInfoTest t25 = new IWMImageInfoTest();
                //t25.DoTests();

                //IWMIndexerTest t26 = new IWMIndexerTest();
                //t26.DoTests();

                //IWMIndexer2Test t27 = new IWMIndexer2Test();
                //t27.DoTests();

                //IWMInputMediaPropsTest t28 = new IWMInputMediaPropsTest();
                //t28.DoTests();

                //IWMIStreamPropsTest t29 = new IWMIStreamPropsTest();
                //t29.DoTests();

                //IWMLanguageListTest t30 = new IWMLanguageListTest();
                //t30.DoTests();

                //IWMLicenseBackupTest t31 = new IWMLicenseBackupTest();
                //t31.DoTests();

                //IWMLicenseRestoreTest t32 = new IWMLicenseRestoreTest();
                //t32.DoTests();

                //IWMMediaPropsTest t33 = new IWMMediaPropsTest();
                //t33.DoTests();

                //IWMMetadataEditorTest t34 = new IWMMetadataEditorTest();
                //t34.DoTests();

                //IWMMetadataEditor2Test t35 = new IWMMetadataEditor2Test();
                //t35.DoTests();

                //IWMMutualExclusionTest t36 = new IWMMutualExclusionTest();
                //t36.DoTests();

                //IWMMutualExclusion2Test t37 = new IWMMutualExclusion2Test();
                //t37.DoTests();

                //IWMOutputMediaPropsTest t38 = new IWMOutputMediaPropsTest();
                //t38.DoTests();

                //IWMPacketSizeTest t39 = new IWMPacketSizeTest();
                //t39.DoTests();

                //IWMPacketSize2Test t40 = new IWMPacketSize2Test();
                //t40.DoTests();

                //IWMPlayerTimestampHookTest t41 = new IWMPlayerTimestampHookTest();
                //t41.DoTests();

                //IWMProfileTest t42 = new IWMProfileTest();
                //t42.DoTests();

                //IWMProfile2Test t43 = new IWMProfile2Test();
                //t43.DoTests();

                //IWMProfile3Test t44 = new IWMProfile3Test();
                //t44.DoTests();

                //IWMProfileManagerTest t45 = new IWMProfileManagerTest();
                //t45.DoTests();

                //IWMProfileManager2Test t46 = new IWMProfileManager2Test();
                //t46.DoTests();

                //IWMProfileManagerLanguageTest t47 = new IWMProfileManagerLanguageTest();
                //t47.DoTests();

                //IWMPropertyVaultTest t48 = new IWMPropertyVaultTest();
                //t48.DoTests();

                //IWMReaderTest t49 = new IWMReaderTest();
                //t49.DoTests();

                //IWMReaderAcceleratorTest t50 = new IWMReaderAcceleratorTest();
                //t50.DoTests();

                //IWMReaderAdvancedTest t51 = new IWMReaderAdvancedTest();
                //t51.DoTests();

                //IWMReaderAdvanced2Test t52 = new IWMReaderAdvanced2Test();
                //t52.DoTests();

                //IWMReaderAdvanced3Test t53 = new IWMReaderAdvanced3Test();
                //t53.DoTests();

                //IWMReaderAdvanced4Test t54 = new IWMReaderAdvanced4Test();
                //t54.DoTests();

                //IWMReaderAllocatorExTest t55 = new IWMReaderAllocatorExTest();
                //t55.DoTests();

                //IWMReaderCallbackTest t56 = new IWMReaderCallbackTest();
                //t56.DoTests();

                //IWMReaderCallbackAdvancedTest t57 = new IWMReaderCallbackAdvancedTest();
                //t57.DoTests();

                //IWMReaderNetworkConfigTest t58 = new IWMReaderNetworkConfigTest();
                //t58.DoTests();

                //IWMReaderNetworkConfig2Test t59 = new IWMReaderNetworkConfig2Test();
                //t59.DoTests();

                //IWMReaderStreamClockTest t60 = new IWMReaderStreamClockTest();
                //t60.DoTests();

                //IWMReaderTimecodeTest t61 = new IWMReaderTimecodeTest();
                //t61.DoTests();

                //IWMReaderTypeNegotiationTest t62 = new IWMReaderTypeNegotiationTest();
                //t62.DoTests();

                //IWMRegisterCallbackTest t63 = new IWMRegisterCallbackTest();
                //t63.DoTests();

                //IWMSBufferAllocatorTest t64 = new IWMSBufferAllocatorTest();
                //t64.DoTests();

                //IWMSInternalAdminNetSourceTest t65 = new IWMSInternalAdminNetSourceTest();
                //t65.DoTests();

                //IWMSInternalAdminNetSource2Test t66 = new IWMSInternalAdminNetSource2Test();
                //t66.DoTests();

                //IWMSInternalAdminNetSource3Test t67 = new IWMSInternalAdminNetSource3Test();
                //t67.DoTests();

                //IWMStatusCallbackTest t68 = new IWMStatusCallbackTest();
                //t68.DoTests();

                //IWMStreamConfigTest t69 = new IWMStreamConfigTest();
                //t69.DoTests();

                //IWMStreamConfig2Test t70 = new IWMStreamConfig2Test();
                //t70.DoTests();

                //IWMStreamConfig3Test t71 = new IWMStreamConfig3Test();
                //t71.DoTests();

                //IWMStreamListTest t72 = new IWMStreamListTest();
                //t72.DoTests();

                //IWMStreamPrioritizationTest t73 = new IWMStreamPrioritizationTest();
                //t73.DoTests();

                //IWMSyncReaderTest t74 = new IWMSyncReaderTest();
                //t74.DoTests();

                //IWMSyncReader2Test t75 = new IWMSyncReader2Test();
                //t75.DoTests();

                //IWMVideoMediaPropsTest t76 = new IWMVideoMediaPropsTest();
                //t76.DoTests();

                //IWMWatermarkInfoTest t77 = new IWMWatermarkInfoTest();
                //t77.DoTests();

                //IWMWriterTest t78 = new IWMWriterTest();
                //t78.DoTests();

                //IWMWriterAdvancedTest t79 = new IWMWriterAdvancedTest();
                //t79.DoTests();

                //IWMWriterAdvanced2Test t80 = new IWMWriterAdvanced2Test();
                //t80.DoTests();

                //IWMWriterAdvanced3Test t81 = new IWMWriterAdvanced3Test();
                //t81.DoTests();

                //IWMWriterFileSinkTest t82 = new IWMWriterFileSinkTest();
                //t82.DoTests();

                //IWMWriterFileSink2Test t83 = new IWMWriterFileSink2Test();
                //t83.DoTests();

                //IWMWriterFileSink3Test t84 = new IWMWriterFileSink3Test();
                //t84.DoTests();

                //IWMWriterNetworkSinkTest t85 = new IWMWriterNetworkSinkTest();
                //t85.DoTests();

                //IWMWriterPostViewTest t86 = new IWMWriterPostViewTest();
                //t86.DoTests();

                //IWMWriterPostViewCallbackTest t87 = new IWMWriterPostViewCallbackTest();
                //t87.DoTests();

                //IWMWriterPreprocessTest t88 = new IWMWriterPreprocessTest();
                //t88.DoTests();

                //IWMWriterPushSinkTest t89 = new IWMWriterPushSinkTest();
                //t89.DoTests();

                //IWMWriterSinkTest t90 = new IWMWriterSinkTest();
                //t90.DoTests();

                //IWMReaderAdvanced5Test t91 = new IWMReaderAdvanced5Test();
                //t91.DoTests();

                //IWMReaderAdvanced6Test t92 = new IWMReaderAdvanced6Test();
                //t92.DoTests();

                //ExternTest t93 = new ExternTest();
                //t93.DoTests();

                //IWMReaderPlaylistBurnTest t94 = new IWMReaderPlaylistBurnTest();
                //t94.DoTests();

                //TestMMIO t95 = new TestMMIO();
                //t95.DoTests();
            }
            catch (Exception e)
            {
                int    hr = Marshal.GetHRForException(e);
                string s  = WMError.GetErrorText(hr);

                if (s == null)
                {
                    s = e.Message;
                }
                else
                {
                    s = string.Format("{0} ({1})", s, e.Message);
                }

                System.Windows.Forms.MessageBox.Show(string.Format("0x{0:x}: {1}", hr, s), "Exception", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
示例#14
0
        //------------------------------------------------------------------------------
        // Name: PrintProperties()
        // Desc: Displays all DRM properties
        //------------------------------------------------------------------------------

        static void PrintProperties(string pwszFileName, string pwszPropertyName)
        {
            string[] g_DRMProperties =
            {
                Constants.g_wszWMDRM_IsDRM,
                Constants.g_wszWMDRM_IsDRMCached,
                Constants.g_wszWMDRM_BaseLicenseAcqURL,
                Constants.g_wszWMDRM_Rights,
                Constants.g_wszWMDRM_LicenseID,

                Constants.g_wszWMDRM_ActionAllowed_Playback,                  //= L\"ActionAllowed.Play\"
                Constants.g_wszWMDRM_ActionAllowed_CopyToCD,                  //= L\"ActionAllowed.Print.redbook\"
                Constants.g_wszWMDRM_ActionAllowed_CopyToSDMIDevice,          //= L\"ActionAllowed.Transfer.SDMI\"
                Constants.g_wszWMDRM_ActionAllowed_CopyToNonSDMIDevice,       //= L\"ActionAllowed.Transfer.NONSDMI\"
                Constants.g_wszWMDRM_ActionAllowed_Backup,                    //= L\"ActionAllowed.Backup\"

                Constants.g_wszWMDRM_DRMHeader,                               //= L\"DRMHeader.\"
                Constants.g_wszWMDRM_DRMHeader_KeyID,                         //= L\"DRMHeader.KID\"
                Constants.g_wszWMDRM_DRMHeader_LicenseAcqURL,                 //= L\"DRMHeader.LAINFO\"
                Constants.g_wszWMDRM_DRMHeader_ContentID,                     //= L\"DRMHeader.CID\"
                Constants.g_wszWMDRM_DRMHeader_IndividualizedVersion,         //= L\"DRMHeader.SECURITYVERSION\"
                Constants.g_wszWMDRM_DRMHeader_ContentDistributor,            //= L\"DRMHeader.ContentDistributor\"
                Constants.g_wszWMDRM_DRMHeader_SubscriptionContentID,         //= L\"DRMHeader.SubscriptionContentID\"
                Constants.g_wszWMDRM_LicenseState_Playback,
                Constants.g_wszWMDRM_LicenseState_CopyToCD,
                Constants.g_wszWMDRM_LicenseState_CopyToSDMIDevice,
                Constants.g_wszWMDRM_LicenseState_CopyToNonSDMIDevice,
                Constants.g_wszWMDRM_LicenseState_Copy,
                Constants.g_wszWMDRM_LicenseState_PlaylistBurn,
                Constants.g_wszWMDRM_LicenseState_CreateThumbnailImage,
                Constants.g_wszWMDRM_LicenseState_Backup,
                Constants.g_wszWMDRM_LicenseState_CollaborativePlay
            };

            CDrmHeaderQuery drmHQ = new CDrmHeaderQuery();

            try
            {
                drmHQ.Open(pwszFileName);
            }
            catch (Exception e)
            {
                int hr = Marshal.GetHRForException(e);
                Console.WriteLine(string.Format("Failed to open file, HR = 0x{0}", hr));
                return;
            }

            try
            {
                if (null != pwszPropertyName)
                {
                    try
                    {
                        string s = drmHQ.GetPropertyAsString(pwszPropertyName);

                        Console.WriteLine(string.Format("{0} :\t{1}", pwszPropertyName, s));
                    }
                    catch (Exception e)
                    {
                        int hr = Marshal.GetHRForException(e);
                        Console.WriteLine(string.Format("Failed to query for the given property. HR = 0x{0}", hr));
                    }
                }
                else
                {
                    foreach (string sProp in g_DRMProperties)
                    {
                        try
                        {
                            string s = drmHQ.GetPropertyAsString(sProp);

                            Console.WriteLine(string.Format("{0} :\t{1}", sProp, s));
                        }
                        catch { }
                    }
                }
            }
            catch (Exception e)
            {
                int    hr = Marshal.GetHRForException(e);
                string s  = WMError.GetErrorText(hr);

                if (s == null)
                {
                    s = e.Message;
                }
                else
                {
                    s = string.Format("{0} ({1})", s, e.Message);
                }

                Console.WriteLine(string.Format("0x{0:x}: {1}", hr, s));
            }
        }