// Create an enumerator hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void**)&pCreateDevEnum); ASSERT(SUCCEEDED(hr)); if (FAILED(hr)) return;
// Use the meta-category that contains a list of all categories. // This emulates the behavior of GraphEdit. hr = pCreateDevEnum->CreateClassEnumerator( CLSID_ActiveMovieCategories, &pEmCat, 0); ASSERT(SUCCEEDED(hr));
if(hr == S_OK) { IMoniker *pMCat; ULONG cFetched;
// Enumerate over every category while(hr = pEmCat->Next(1, &pMCat, &cFetched), hr == S_OK) { IPropertyBag *pPropBag;
// Associate moniker with a file hr = pMCat->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); if(SUCCEEDED(hr)) { VARIANT varCatClsid; varCatClsid.vt = VT_BSTR;
// Read CLSID string from property bag hr = pPropBag->Read(L"CLSID", &varCatClsid, 0); if(SUCCEEDED(hr)) { CLSID clsidCat;//枚举所有的设备类
if(CLSIDFromString(varCatClsid.bstrVal, &clsidCat) == S_OK) { // Use the guid if we can‘t get the name WCHAR *wszCatName; TCHAR szCatDesc[MAX_PATH];