zoukankan      html  css  js  c++  java
  • directX根据设备类GUID查询所属的filter 分类: DirectX 2014-09-20 08:34 501人阅读 评论(0) 收藏

    hr = m_pSysDevEnum->CreateClassEnumerator(*clsid, &pEnumCat, 0);
        ASSERT(SUCCEEDED(hr));
        if FAILED(hr)
            return;


        // Enumerate all filters using the category enumerator
        hr = EnumFilters(pEnumCat);


    IBaseFilter *buf[20];

    HRESULT CSysEnumDlg::EnumFilters(IEnumMoniker *pEnumCat)
    {
        HRESULT hr=S_OK;
        IMoniker *pMoniker;
        ULONG cFetched;
        VARIANT varName={0};
        int nFilters=0;
        IBaseFilter * pSrc = NULL;
        // Clear the current filter list
        ClearFilterList();


        // If there are no filters of a requested type, show default string
        if (!pEnumCat)
        {
            m_FilterList.AddString(TEXT("<< No entries >>"));
            SetNumFilters(nFilters);
            return S_FALSE;
        }


        // Enumerate all items associated with the moniker
        while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
        {
            IPropertyBag *pPropBag;
            ASSERT(pMoniker);


            // Associate moniker with a file
            hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, 
                                        (void **)&pPropBag);
            ASSERT(SUCCEEDED(hr));
            ASSERT(pPropBag);
            if (FAILED(hr))
                continue;


            // Read filter name from property bag
            varName.vt = VT_BSTR;
            hr = pPropBag->Read(L"FriendlyName", &varName, 0);
            if (FAILED(hr))
                continue;


            // Get filter name (converting BSTR name to a CString)
            CString str(varName.bstrVal);

    /*

           if(hr == NOERROR)//根据名称检索filter
            {
    CString str(varName.bstrVal);


    if (str.Find("Virtual Camera",0)!=-1)
    {
    hr = pMoniker->BindToObject(0,0,IID_IBaseFilter, (void**)&pSrc);
    if (FAILED(hr))
    {
    //  Msg(TEXT("Couldn't bind moniker to filter object!  hr=0x%x"), hr);
    break;
    }
    break;
    }

    }

    */

            SysFreeString(varName.bstrVal);
            
    //////////////////////////////////////////
            hr = pMoniker->BindToObject(0,0,IID_IBaseFilter, (void**)&pSrc);
    if (FAILED(hr))
                AfxMessageBox(_T("err001"),MB_OK,NULL);
    buf[nFilters] = pSrc;//保持当前的设备类的所有的filter

    /////////////////////////////////////////////
    nFilters++;
            // Read filter's CLSID from property bag.  This CLSID string will be
            // converted to a binary CLSID and passed to AddFilter(), which will
            // add the filter's name to the listbox and its CLSID to the listbox
            // item's DataPtr item.  When the user clicks on a filter name in
            // the listbox, we'll read the stored CLSID, convert it to a string,
            // and use it to find the filter's filename in the registry.
            VARIANT varFilterClsid;
            varFilterClsid.vt = VT_BSTR;


            // Read CLSID string from property bag
            hr = pPropBag->Read(L"CLSID", &varFilterClsid, 0);
            if(SUCCEEDED(hr))
            {
                CLSID clsidFilter;


                // Add filter name and CLSID to listbox
                if(CLSIDFromString(varFilterClsid.bstrVal, &clsidFilter) == S_OK)
                {
                    AddFilter(str, &clsidFilter);
                }


                SysFreeString(varFilterClsid.bstrVal);
            }
           
            // Cleanup interfaces
            SAFE_RELEASE(pPropBag);
            SAFE_RELEASE(pMoniker);
        }


        // Update count of enumerated filters
        SetNumFilters(nFilters);
        return hr;
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    我的Java学习推荐书目
    BTrace使用简介
    BTrace使用小结
    如何在生产环境使用Btrace进行调试
    BTrace : Java 线上问题排查神器
    淘宝Tprofiler工具实现分析
    JVM 性能调优实战之:使用阿里开源工具 TProfiler 在海量业务代码中精确定位性能代码
    性能工具TProfiler介绍文档
    分布式系统理论基础
    微信小程序
  • 原文地址:https://www.cnblogs.com/mao0504/p/4706517.html
Copyright © 2011-2022 走看看