Listing the codecs intalled on the machine

Listing the codecs intalled on the machine

  • Comments 2

Often an application requires to list all the Audio/Video compressors installed on the machine. We can achieve this easily with the ICreateDevEnum interface available from DirectShow. ICreateDevEnum exposes a method named CreateClassEnumerator that allows us to create enumerators for different categories of devices, such as audio/video codecs, Directx Media Objects (DMO) etc.

The typical usage is as shown below:

     CComPtr<ICreateDevEnum> pSysDevEnum;
    if(FAILED(hr = pSysDevEnum.CoCreateInstance(CLSID_SystemDeviceEnum)))
        return hr;
    IEnumMoniker *pEnum = NULL;
    hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoCompressorCategory, &pEnum, 0);
    if (hr == S_OK) 
        // Use the pEnum to enumerate the devices
        // Do not forget to release it when done.

The below code enumerates the Audio compressors available on the machine and adds their friendly names to an application defined combo box.

HRESULT CAudioConvertDlg::AddCompressorsToComboList(CString *pStrErrMsg)
    HRESULT hr = E_FAIL;


    CComPtr<ICreateDevEnum> pCreateDevEnum;
    if(FAILED(hr = pCreateDevEnum.CoCreateInstance(CLSID_SystemDeviceEnum)))
        *pStrErrMsg += "Unable to Create System Device Enumerator";	return hr;
    CComPtr<IEnumMoniker> pEnumMoniker;
    if(FAILED(hr = pCreateDevEnum->CreateClassEnumerator(CLSID_AudioCompressorCategory,&pEnumMoniker,0)))
        *pStrErrMsg += "Unable to Create AudioCompressor Enumerator";	return hr;
    CComPtr<IMoniker> pMoniker;
    while(pEnumMoniker->Next(1,&pMoniker,NULL) == S_OK)
        CComPtr<IPropertyBag> pBag;	// Use the Moniker's PropertyBag to get the Object's name
            VARIANT var;
            var.vt = VT_BSTR;
                TCHAR szName[512];


    return hr = S_OK;   // Everything went fine !!
  • I try this, but not all directshow codec can be list.

  • i don't find out audio compress codec.

Page 1 of 1 (2 items)
Leave a Comment
  • Please add 3 and 1 and type the answer here:
  • Post