Wednesday, March 28, 2007

registering and Unregistering a filter in a specified category....

STDAPI DllRegisterServer()
{
OutputDebugString("\n DllRegisterServer() fn");
HRESULT hr = NOERROR;

hr = AMovieDllRegisterServer2( TRUE );

if(FAILED(hr))
{
return hr;
}


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();
}

return hr;

} // DllRegisterServer

//
// DllUnregisterServer
//
STDAPI DllUnregisterServer()
{
OutputDebugString("\n DllUnRegisterServer fn" );
HRESULT hr = NOERROR;


hr = AMovieDllRegisterServer2( FALSE );

if(FAILED(hr))
{
return hr;
}


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, // 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>>>");
}


return hr;

} // DllUnregisterServer

Labels:

0 Comments:

Post a Comment

<< Home