• 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;
    }

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

  • 相关阅读:
    第三章 对话拖延--摆脱拖延
    第二章 审问拖延:被架在审判席上的失败者恐惧症
    番茄学习法笔记以及初始尝试
    第一章 质疑拖延:是可恶的坏习惯还是应得的报应
    学习编程珠玑笔记记录-----第二章 算法
    李文业工作一年总结
    永远要努力向前
    怎样才能在工作中进步的更快
    windows下php扩展安装
    JS学习笔记
  • 原文地址:https://www.cnblogs.com/mao0504/p/4706517.html
Copyright © 2020-2023  润新知