Wednesday, March 28, 2007

Registering our filter in a specified category...

IFilterMapper2* pFM2 = NULL;
hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
IID_IFilterMapper2, (void **)&pFM2);

if (SUCCEEDED(hr))
{
// Declare filter information
const REGFILTER2 rf2AbsDiffReg =
{
1, // Version number
MERIT_DO_NOT_USE+1, // Filter merit
2, // Number of pins
sudpPins // Pin information
};

hr = pFM2->RegisterFilter(
CLSID_AbsDiff, // Filter CLSID.
TRANSFORM_NAME, // Filter name.
NULL, // Device moniker.
&CLSID_BDLImageProcessing, // DirectShow filter
TRANSFORM_NAME, // Instance data.
// This instance data is an essential thing...
&rf2AbsDiffReg // Filter information.
);
pFM2->Release();
}





Today I faced the problem I am not able to unregister the filter....


the reason is
For UnregisterFilter(), i passed the NULL as an instance data... (check the documentation) even though I have given valid class ID...




following code for unregistering the filter:



IFilterMapper2* pFM2 = NULL;
hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
IID_IFilterMapper2, (void **)&pFM2);

if (SUCCEEDED(hr))
{
hr = pFM2->UnregisterFilter(
&CLSID_BDLImageProcessing, // Filter CLSID.
TRANSFORM_NAME,
// I passed this value as NULL So i got a problem // Filter name.
CLSID_AbsDiff // Device moniker.
);
if(SUCCEEDED(hr))
{
OutputDebugString("\n Sucessfully Unregistered ");
}
else
{
OutputDebugString("\n UnRegistration failed...");
}
pFM2->Release();
}
else
{
OutputDebugString("\n Error in IFilterMapper2 Interface problems>>>");
}



So it failed...

No comments: