Microsoft DirectX 9.0

Enumerating Effects and Transitions

DirectShow provides a System Device Enumerator object for enumerating devices. You can use it to retrieve monikers for effects or transitions installed on the user's system.

The system device enumerator exposes the ICreateDevEnum interface. It returns category enumerators for specified device categories. A category enumerator, in turn, exposes the IEnumMoniker interface and returns monikers for each device in the category. For a detailed discussion of using ICreateDevEnem, see Enumerating Devices and Filters. The following is a brief summary, specific to DirectShow Editing Services.

To enumerate effects or transitions, perform the following steps.

  1. Create an instance of the system device enumerator.
  2. Call the ICreateDevEnum::CreateClassEnumerator method to retrieve a category enumerator. Categories are defined by class identifiers (CLSIDs). Use CLSID_VideoEffects1Category for effects or CLSID_VideoEffects2Category for transitions.
  3. Call IEnumMoniker::Next to retrieve each moniker in the enumeration.
  4. For each moniker, call IMoniker::BindToStorage to retrieve its associated property bag.

The property bag contains the friendly name and the globally unique identifier (GUID) for the effect or transition. An application can display a list of friendly names and then obtain the corresponding GUID.

The following code example illustrates these steps.

ICreateDevEnum *pCreateDevEnum = NULL;
IEnumMoniker *pEnumMoniker = NULL;

// Create the System Device Enumerator.
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, 
    CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void**)&pCreateDevEnum);
if (FAILED(hr))
{
    // Error handling omitted for clarity.
}

// Create an enumerator for the video effects category.
hr = pCreateDevEnum->CreateClassEnumerator(
    CLSID_VideoEffects1Category,  // Video effects category. 
    &pEnumMoniker, 0);               

// Note: Use CLSID_VideoEffects2Category for video transitions.

if (hr == S_OK)  // S_FALSE means the category is empty.
{
    // Enumerate each video effect.
    IMoniker *pMoniker;
    while (S_OK == pEnumMoniker->Next(1, &pMoniker, NULL))
    {
        IPropertyBag *pBag;
        hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, 
            (void **)&pBag);
        if(FAILED(hr))
        {
            pMoniker->Release();
            continue; // Maybe the next one will work.
        }
        VARIANT var;
        VariantInit(&var);
        hr = pBag->Read(OLESTR("FriendlyName"), &var, NULL);
        if (SUCCEEDED(hr))
        {
            if ( ... )  // Check if var.bstrVal is the name you want.
            {
                VARIANT var2;
                GUID guid;
                var2.vt = VT_BSTR;
                pBag->Read(OLESTR("guid"), &var2, NULL);
                CLSIDFromString(var2.bstrVal, &guid);
                VariantClear(&var2);
                // GUID is now the CLSID for the effect.
            }
        }
        VariantClear(&var);
        pBag->Release();
        pMoniker->Release();
    }
    pEnumMoniker->Release();
}
pCreateDevEnum->Release();