Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <dshow.h>
- #include <iostream>
- #include <mmdeviceapi.h>
- #include <uuids.h>
- void print_device() {
- // Create the System Device Enumerator.
- HRESULT hr;
- ICreateDevEnum *pSysDevEnum = NULL;
- hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
- IID_ICreateDevEnum, (void **)&pSysDevEnum);
- if (FAILED(hr))
- {
- return;
- }
- // Obtain a class enumerator for the video compressor category.
- IEnumMoniker *pEnumCat = NULL;
- hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoCompressorCategory, &pEnumCat, 0);
- if (hr == S_OK)
- {
- // Enumerate the monikers.
- IMoniker *pMoniker = NULL;
- ULONG cFetched;
- while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
- {
- IPropertyBag *pPropBag;
- hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag,
- (void **)&pPropBag);
- if (SUCCEEDED(hr))
- {
- // To retrieve the filter's friendly name, do the following:
- VARIANT varName;
- VariantInit(&varName);
- hr = pPropBag->Read(L"FriendlyName", &varName, 0);
- if (SUCCEEDED(hr))
- {
- std::wcout << varName.bstrVal << 'n';
- }
- VariantClear(&varName);
- }
- pMoniker->Release();
- }
- pEnumCat->Release();
- }
- pSysDevEnum->Release();
- }
- int main() {
- // Initializes
- CoInitialize( NULL );
- // loop to test leak
- while( true ) {
- print_device();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement