hello:
in my impression that filters that appear in graphedit have been registered.so we can use it directly.
but this time i have a touble about it.
when i use coCreateInstace function to create a special filter in my code ,my complier
reports erro.
it reports that no registered. and i have to register it in my code:
//
OUR_GUID_ENTRY(CLSID_MPEG4s_decoder,
0x4a69e442,0x28be,0x4991, 0x96, 0x9c,0xb5, 0x00, 0xad ,0xf5,0xd8,0xa8);
BOOL pass=FALSE ;
if(!IsFilterRegistered(CLSID_MPEG4s_decoder))
pass = RegisterFilter(TEXT("C:\\Windows\\System32\\MP4SDECD.DLL"));
if(pass) //break here ,the pass value =true
hr =AddFilterByClSID(pGraph,CLSID_MPEG4s_decoder,
TEXT("MPEG4s Decoder DMO"),&pMPEG4sDecoder);
if(FAILED(hr))//but here ,hr =0x80040154
return FALSE ;
HRESULT CPlayer::AddFilterByClSID(
IFilterGraph *pfG,
const GUID & clsid,
LPCWSTR wszName,
IBaseFilter ** ppf)
{
if(!pfG || !ppf )
return E_POINTER ;
(*ppf) = 0 ;
IBaseFilter * pF =0 ;
HRESULT hr = CoCreateInstance(
clsid,
NULL,
CLSCTX_INPROC,
IID_IBaseFilter,
reinterpret_cast<void>(&pF));
if(SUCCEEDED(hr))
{
hr = pfG->AddFilter(pF,wszName);
if(SUCCEEDED(hr))
*ppf=pF ;
else
pF->Release();
}
return hr ;
}
BOOL CPlayer::IsFilterRegistered(CLSID infilerId)
{
IBaseFilter * pFilter = NULL ;
if(SUCCEEDED(
CoCreateInstance(infilerId,NULL,CLSCTX_INPROC_SERVER,IID_IBaseFilter,
(void**)&pFilter) ) )
{
pFilter->Release();
return TRUE ;
}
return FALSE ;
}