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

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

  • 相关阅读:
    PHP遍历数组元素
    In PHP5, what is the difference between using self and $this? When is each appropriate?
    了解如何构建 Metro 样式的应用程序
    HTML5在路上
    meta 之 viewport
    dede数据库连接文件
    windows 环境安装wamp软件实现php开发环境
    域名空间那些事
    Javascript编程风格
    apache 服务器修改网站默认首页
  • 原文地址:https://www.cnblogs.com/mao0504/p/4706517.html
Copyright © 2020-2023  润新知