Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #include <dshow.h>
  2. #include <iostream>
  3. #include <mmdeviceapi.h>
  4. #include <uuids.h>
  5.  
  6. void print_device() {
  7. // Create the System Device Enumerator.
  8. HRESULT hr;
  9. ICreateDevEnum *pSysDevEnum = NULL;
  10. hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
  11. IID_ICreateDevEnum, (void **)&pSysDevEnum);
  12. if (FAILED(hr))
  13. {
  14. return;
  15. }
  16.  
  17. // Obtain a class enumerator for the video compressor category.
  18. IEnumMoniker *pEnumCat = NULL;
  19. hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoCompressorCategory, &pEnumCat, 0);
  20.  
  21. if (hr == S_OK)
  22. {
  23. // Enumerate the monikers.
  24. IMoniker *pMoniker = NULL;
  25. ULONG cFetched;
  26. while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
  27. {
  28. IPropertyBag *pPropBag;
  29. hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag,
  30. (void **)&pPropBag);
  31. if (SUCCEEDED(hr))
  32. {
  33. // To retrieve the filter's friendly name, do the following:
  34. VARIANT varName;
  35. VariantInit(&varName);
  36. hr = pPropBag->Read(L"FriendlyName", &varName, 0);
  37. if (SUCCEEDED(hr))
  38. {
  39. std::wcout << varName.bstrVal << 'n';
  40. }
  41. VariantClear(&varName);
  42. }
  43. pMoniker->Release();
  44. }
  45. pEnumCat->Release();
  46. }
  47. pSysDevEnum->Release();
  48. }
  49.  
  50. int main() {
  51. // Initializes
  52. CoInitialize( NULL );
  53.  
  54. // loop to test leak
  55. while( true ) {
  56. print_device();
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement