directX根据设备类GUID查询所属的filter

简介: hr = m_pSysDevEnum->CreateClassEnumerator(*clsid, &pEnumCat, 0);<br>    ASSERT(SUCCEEDED(hr));<br>    if FAILED(hr)<br>        return;<br><br><br>    // Enumerate all filters using the catego
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;
}

相关文章
|
8月前
uView guid 全局唯一标识符
uView guid 全局唯一标识符
62 0
|
8月前
|
存储 算法 数据库
【C++ 软件设计思路】学习C++中如何生成唯一标识符:从UUID到自定义规则
【C++ 软件设计思路】学习C++中如何生成唯一标识符:从UUID到自定义规则
374 0
SwiftUI—如何通过AnyView返回任意类型的视图
SwiftUI—如何通过AnyView返回任意类型的视图
272 0
SwiftUI—如何通过AnyView返回任意类型的视图
【TP5.1】创建通用的基类自定义命令
【TP5.1】创建通用的基类自定义命令
114 0
【TP5.1】创建通用的基类自定义命令
|
算法 关系型数据库 MySQL
全局唯一数字ID生成子系统
GUID 雪花算法 snowflake uid-generator
166 0
|
SQL 算法 数据库
|
Linux C++ Windows
C++:在程序中获取全球唯一标识号(GUID或UUID)
Windows:使用CoCreateGuid函数(GUID) #include #include #define GUID_LEN 64 int main(int argc, char* argv[]){ char buffer[GUID_LEN] = { 0 }; GUID guid; ...
8944 0

热门文章

最新文章