Microsoft DirectX 8.1 (C++) |
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.
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;
IEnumMoniker *pEm;
CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (void**)&pCreateDevEnum);
pCreateDevEnum->CreateClassEnumerator(
CLSID_VideoEffects1Category, // Effects category.
&pEnumMoniker, 0); // Use CLSID_VideoEffects2Category for transitions.
ULONG cFetched;
IMoniker *pMoniker;
while(S_OK == pEnumMoniker->Next(1, &pMoniker, &cFetched))
{
HRESULT hr;
IPropertyBag *pBag;
hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
if(SUCCEEDED(hr))
{
VARIANT var;
var.vt = VT_BSTR;
hr = pBag->Read(OLESTR("FriendlyName"), &var, NULL);
if (SUCCEEDED(hr))
{
if ( ... ) // Check whether var.bstrVal is the name you want.
{
VARIANT var2;
GUID guid;
pBag->Read(OLESTR("guid"), &var2, NULL);
CLSIDFromString(var2.bstrVal, &guid);
SysFreeString(var2.bstrVal);
// GUID is now the CLSID for the effect.
break;
}
SysFreeString(var.bstrVal);
}
pBag->Release();
}
pMoniker->Release();
}
pEnumMoniker->Release();
pCreateDevEnum->Release();