⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csdn_文档中心_视频捕获 之 如何使用系统设备枚举器.htm

📁 csdn10年中间经典帖子
💻 HTM
📖 第 1 页 / 共 4 页
字号:
                style="BACKGROUND-COLOR: transparent; BORDER-BOTTOM: silver 1pt solid; BORDER-LEFT: silver 1pt solid; BORDER-RIGHT: silver 1pt solid; BORDER-TOP: silver 1pt solid; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; WIDTH: 426.1pt; mso-border-alt: solid silver .5pt" 
                vAlign=top width=568><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt">//</SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">生成系统设备枚举器<SPAN lang=EN-US>.<o:p></o:p></SPAN></SPAN></CODE></FONT></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>HRESULT hr;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>ICreateDevEnum *pSysDevEnum = NULL;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>IID_ICreateDevEnum, (void **)&amp;pSysDevEnum);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>if (FAILED(hr))<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>{<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>return hr;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>}<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><o:p><FONT face=宋体>&nbsp;</FONT></o:p></SPAN></CODE></PRE><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt">// </SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">获得视频压缩的类枚举器(<SPAN lang=EN-US>Class enumerator</SPAN>)<SPAN lang=EN-US>.<o:p></o:p></SPAN></SPAN></CODE></FONT></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>IEnumMoniker *pEnumCat = NULL;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>hr = pSysDevEnum-&gt;CreateClassEnumerator(CLSID_VideoCompressorCategory, &amp;pEnumCat, 0);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><o:p><FONT face=宋体>&nbsp;</FONT></o:p></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>if (hr == S_OK) <o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>{<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>// </SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">枚举其中的<SPAN lang=EN-US> moniker.<o:p></o:p></SPAN></SPAN></CODE></FONT></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>IMoniker *pMoniker = NULL;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>ULONG cFetched;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>while(pEnumCat-&gt;Next(1, &amp;pMoniker, &amp;cFetched) == S_OK)<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>IPropertyBag *pPropBag;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>hr = pMoniker-&gt;BindToStorage(0, 0, IID_IPropertyBag, <o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>(void **)&amp;pPropBag);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>if (SUCCEEDED(hr))<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>//</SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">如下,得到<SPAN lang=EN-US>Filter</SPAN>的友好名称<SPAN lang=EN-US>:<o:p></o:p></SPAN></SPAN></CODE></FONT></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>VARIANT varName;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>VariantInit(&amp;varName);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>hr = pPropBag-&gt;Read(L"FriendlyName", &amp;varName, 0);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>if (SUCCEEDED(hr))<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>//</SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">在你的用户界面上面显示<SPAN lang=EN-US>.<o:p></o:p></SPAN></SPAN></CODE></FONT></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>VariantClear(&amp;varName);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><o:p><FONT face=宋体>&nbsp;</FONT></o:p></SPAN></CODE></PRE><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// </SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">如下,生成该<SPAN lang=EN-US>filter</SPAN>的实例<SPAN lang=EN-US>:<o:p></o:p></SPAN></SPAN></CODE></FONT></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>IBaseFilter *pFilter;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>hr = pMoniker-&gt;BindToObject(NULL, NULL, IID_IBaseFilter,<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>(void**)&amp;pFilter);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>//</SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">将<SPAN lang=EN-US>Filter</SPAN>加入到<SPAN lang=EN-US>Graph. <o:p></o:p></SPAN></SPAN></CODE></FONT></PRE><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>//</SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">后面必须记得释放<SPAN lang=EN-US>pFilter.<o:p></o:p></SPAN></SPAN></CODE></FONT></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>pPropBag-&gt;Release();<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>pMoniker-&gt;Release();<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>pEnumCat-&gt;Release();<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>}<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>pSysDevEnum-&gt;Release();<o:p></o:p></FONT></SPAN></CODE></PRE>
                  <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                  lang=EN-US><o:p><FONT color=#000000 face="Times New Roman" 
                  size=3>&nbsp;</FONT></o:p></SPAN></P></TD></TR></TBODY></TABLE></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B 
            style="mso-bidi-font-weight: normal"><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设备</SPAN><SPAN 
            lang=EN-US><FONT 
            face="Times New Roman">Moniker<o:p></o:p></FONT></SPAN></B></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
            lang=EN-US><FONT 
            face="Times New Roman">IMoniker::GetDisplayName</FONT></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法返回</SPAN><SPAN 
            lang=EN-US><FONT face="Times New Roman">moniker</FONT></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的名字。你可以把这个名字传递给</SPAN><SPAN 
            lang=EN-US><A 
            href="mk:@MSITStore:D:\DXSDK\Doc\DirectX9\DirectX9_c.chm::/directx/htm/ifiltergraph2addsourcefilterformoniker.htm"><SPAN 
            style="COLOR: windowtext; TEXT-DECORATION: none; text-underline: none"><FONT 
            face="Times New Roman">IFilterGraph2::AddSourceFilterForMoniker</FONT></SPAN></A></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,这样可以生成该设备的捕获</SPAN><SPAN 
            lang=EN-US><FONT face="Times New Roman">Filter</FONT></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</SPAN></P>
            <P>
            <TABLE border=1 cellPadding=0 cellSpacing=0 class=MsoTableGrid 
            style="BACKGROUND: silver; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; BORDER-LEFT: medium none; BORDER-RIGHT: medium none; BORDER-TOP: medium none; mso-border-alt: solid silver .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid silver; mso-border-insidev: .5pt solid silver">
              <TBODY>
              <TR 
              style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
                <TD 
                style="BACKGROUND-COLOR: transparent; BORDER-BOTTOM: silver 1pt solid; BORDER-LEFT: silver 1pt solid; BORDER-RIGHT: silver 1pt solid; BORDER-TOP: silver 1pt solid; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; WIDTH: 426.1pt; mso-border-alt: solid silver .5pt" 
                vAlign=top width=568><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>LPOLESTR strName = NULL;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>IBaseFilter pSrc = NULL;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>hr = pMoniker-&gt;GetDisplayName(NULL, NULL, &amp;strName);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>if (SUCCEEDED(hr))<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>{<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>// </SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">得到<SPAN lang=EN-US>IFilterGraph2</SPAN>的<SPAN lang=EN-US>Filter Graph Manager.<o:p></o:p></SPAN></SPAN></CODE></FONT></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>IFilterGraph2 *pFG2 = NULL;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>hr = pGraph-&gt;QueryInterface(IID_IFilterGraph2, (void**)&amp;pFG2);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>if (SUCCEEDED(hr))<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>hr = pFG2-&gt;AddSourceFilterForMoniker(pMoniker, 0, L"Source", &amp;pSrc);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>pFG2-&gt;Release();<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>CoTaskMemFree(strName);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>}<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><o:p><FONT face=宋体>&nbsp;</FONT></o:p></SPAN></CODE></PRE><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt">// </SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">如果成功,记得释放<SPAN lang=EN-US>pSrc.<o:p></o:p></SPAN></SPAN></CODE></FONT></PRE>
                  <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                  lang=EN-US><o:p><FONT color=#000000 face="Times New Roman" 
                  size=3>&nbsp;</FONT></o:p></SPAN></P></TD></TR></TBODY></TABLE></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">虽然,用上述方法得到的名字也有较好的可读性,但是我们一般不把它显示给用户,如前面所示,我们一般用从</SPAN><SPAN 
            lang=EN-US 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 10pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">IPropertyBag</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">得到的名字。</SPAN></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法</SPAN><SPAN 
            lang=EN-US><FONT 
            face="Times New Roman">IMoniker::ParseDisplayName</FONT></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN 
            lang=EN-US><FONT 
            face="Times New Roman">MkParseDisplayName</FONT></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以用来生成指定</SPAN><SPAN 
            lang=EN-US><FONT face="Times New Roman">filter</FONT></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类型的设备的</SPAN><SPAN 
            lang=EN-US><FONT face="Times New Roman">moniker</FONT></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。名字以“</SPAN><FONT 
            face=宋体><CODE><SPAN lang=EN-US 
            style="FONT-SIZE: 12pt">@device:*:{category-clsid}</SPAN></CODE><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">”,代表了类型的</SPAN><SPAN 
            lang=EN-US><FONT face="Times New Roman">GUID</FONT></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,默认的</SPAN><SPAN 
            lang=EN-US><FONT face="Times New Roman">moniker</FONT></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是设备枚举器中的第一个</SPAN><SPAN 
            lang=EN-US><FONT face="Times New Roman">moniker</FONT></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</SPAN></FONT></P>
            <P>
            <TABLE border=1 cellPadding=0 cellSpacing=0 class=MsoTableGrid 
            style="BACKGROUND: silver; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; BORDER-LEFT: medium none; BORDER-RIGHT: medium none; BORDER-TOP: medium none; mso-border-alt: solid silver .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid silver; mso-border-insidev: .5pt solid silver">
              <TBODY>
              <TR 
              style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
                <TD 
                style="BACKGROUND-COLOR: transparent; BORDER-BOTTOM: silver 1pt solid; BORDER-LEFT: silver 1pt solid; BORDER-RIGHT: silver 1pt solid; BORDER-TOP: silver 1pt solid; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; WIDTH: 426.1pt; mso-border-alt: solid silver .5pt" 
                vAlign=top width=568><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt">//</SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">视频捕获类型<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></CODE></FONT></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>WCHAR szMon[] = L"@device:*:{860BB310-5D01-11d0-BD3B<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="True" HasSpace="False" SourceValue="0" UnitName="a">-00A</st1:chmetcnv><st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="0" UnitName="C">0C</st1:chmetcnv>911CE86}";<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>IBindCtx *pBindCtx;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>hr = CreateBindCtx(0, &amp;pBindCtx);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><o:p><FONT face=宋体>&nbsp;</FONT></o:p></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>ULONG chEaten = 0;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>IMoniker *pMoniker = 0;<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>hr = MkParseDisplayName(pBindCtx, szMon, &amp;chEaten, &amp;pMoniker);<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>pBindCtx-&gt;Release();<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>if (SUCCEEDED(hr))<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>{<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><FONT face=宋体><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>// </SPAN></CODE><CODE><SPAN style="COLOR: maroon; FONT-SIZE: 10.5pt">得到名字或绑定至<SPAN lang=EN-US>DirectShow Filter.<o:p></o:p></SPAN></SPAN></CODE></FONT></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>pMoniker-&gt;Release();<o:p></o:p></FONT></SPAN></CODE></PRE><PRE><CODE><SPAN lang=EN-US style="COLOR: maroon; FONT-SIZE: 10.5pt"><FONT face=宋体>}<o:p></o:p></FONT></SPAN></CODE></PRE>
                  <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                  lang=EN-US><o:p><FONT color=#000000 face="Times New Roman" 
                  size=3>&nbsp;</FONT></o:p></SPAN></P></TD></TR></TBODY></TABLE></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
            lang=EN-US><o:p><FONT 
            face="Times New Roman">&nbsp;</FONT></o:p></SPAN></P><BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center bgColor=#006699 border=0 cellPadding=0 cellSpacing=0 
width=770>
  <TBODY>
  <TR bgColor=#006699>
    <TD align=middle bgColor=#006699 id=white><FONT 
    color=#ffffff>对该文的评论</FONT></TD>
    <TD align=middle>
      <SCRIPT src="CSDN_文档中心_视频捕获 之 如何使用系统设备枚举器.files/readnum.htm"></SCRIPT>
    </TD></TR></TBODY></TABLE><BR>
<DIV align=center>
<TABLE align=center bgColor=#cccccc border=0 cellPadding=2 cellSpacing=1 
width=770>
  <TBODY>
  <TR>
    <TH bgColor=#006699 id=white><FONT 
color=#ffffff>我要评论</FONT></TH></TR></TBODY></TABLE></DIV>
<DIV align=center>
<TABLE border=0 width=770>
  <TBODY>
  <TR>
    <TD>你没有登陆,无法发表评论。 请先<A 
      href="http://www.csdn.net/member/login.asp?from=/Develop/read_article.asp?id=26777">登陆</A> 
      <A 
href="http://www.csdn.net/expert/zc.asp">我要注册</A><BR></TD></TR></TBODY></TABLE></DIV><BR>
<HR noShade SIZE=1 width=770>

<TABLE border=0 cellPadding=0 cellSpacing=0 width=500>
  <TBODY>
  <TR align=middle>
    <TD height=10 vAlign=bottom><A 
      href="http://www.csdn.net/intro/intro.asp?id=2">网站简介</A> - <A 
      href="http://www.csdn.net/intro/intro.asp?id=5">广告服务</A> - <A 
      href="http://www.csdn.net/map/map.shtm">网站地图</A> - <A 
      href="http://www.csdn.net/help/help.asp">帮助信息</A> - <A 
      href="http://www.csdn.net/intro/intro.asp?id=2">联系方式</A> - <A 
      href="http://www.csdn.net/english">English</A> </TD>
    <TD align=middle rowSpan=3><A 
      href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010"><IMG 
      border=0 height=48 src="CSDN_文档中心_视频捕获 之 如何使用系统设备枚举器.files/biaoshi.gif" 
      width=40></A></TD></TR>
  <TR align=middle>
    <TD vAlign=top>百联美达美公司 版权所有 京ICP证020026号</TD></TR>
  <TR align=middle>
    <TD vAlign=top><FONT face=Verdana>Copyright &copy; CSDN.net, Inc. All rights 
      reserved</FONT></TD></TR>
  <TR>
    <TD height=15></TD>
    <TD></TD></TR></TBODY></TABLE></DIV>
<DIV></DIV><!--内容结束//--><!--结束//--></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -