protected UCOMIMoniker GetAnyMoniker()
{
Guid category = Uuid.FilterCategory.VideoCompressorCategory;
int hr;
object comObj = null;
ICreateDevEnum enumDev = null;
UCOMIEnumMoniker enumMon = null;
UCOMIMoniker[] mon = new UCOMIMoniker[1];
try
{
// Get the system device enumerator
Type srvType = Type.GetTypeFromCLSID(Uuid.Clsid.SystemDeviceEnum);
if (srvType == null)
throw new NotImplementedException("System Device Enumerator");
comObj = Activator.CreateInstance(srvType);
enumDev = (ICreateDevEnum)comObj;
//Create an enumerator to find filters in category
hr = enumDev.CreateClassEnumerator(ref category, out enumMon, 0);
if (hr != 0)
throw new NotSupportedException("No devices of the category");
// Get first filter
int f;
hr = enumMon.Next(1, mon, out f);
if ((hr != 0))
mon[0] = null;
return (mon[0]);
}
finally
{
enumDev = null;
if (enumMon != null)
Marshal.ReleaseComObject(enumMon); enumMon = null;
if (comObj != null)
Marshal.ReleaseComObject(comObj); comObj = null;
}
}