void CCaremaDlg::OnButton1()
{
::CoInitialize(NULL);
// IID myroupName = CLSID_SystemDeviceEnum;
IID myroupName = CLSID_LegacyAmFilterCategory;
IBaseFilter* pFilter = this->FindFilterByClsId(myroupName,"Video Renderer");
int i=0;
}
IBaseFilter* CCaremaDlg::FindFilterByClsId(IID Typeid, CString comName)
{
ICreateDevEnum* pAllDevSource = NULL;
IBaseFilter* pFilter = NULL;
HRESULT hr = ::CoCreateInstance(CLSID_SystemDeviceEnum,NULL,CLSCTX_INPROC_SERVER,IID_ICreateDevEnum,(void**)&pAllDevSource);
if(FAILED(hr)){
MessageBox("Faild!");
}
MessageBox("Success!");
//找出了系统设备
IEnumMoniker* pEnumMoniker = NULL;
ULONG dsize = 0;
hr = pAllDevSource->CreateClassEnumerator(Typeid,&pEnumMoniker,0);
if( hr != S_OK ){
MessageBox("IEnumMoniker Faild!");
}
MessageBox("IEnumMoniker Success!");
IMoniker* pMoniker = NULL;
while( pEnumMoniker->Next(1,&pMoniker,&dsize)==S_OK )
{
IPropertyBag* pProperty = NULL;
if( SUCCEEDED(pMoniker->BindToStorage(NULL,NULL,IID_IPropertyBag,(void**)&pProperty)) )
{
VARIANT DevName;
VariantInit(&DevName);
DevName.vt = VT_BSTR;
pProperty->Read( L"Friendlyname", &DevName, 0 );
CString str(DevName.bstrVal);
VariantClear(&DevName);
MessageBox(str);
if( str == comName )
{
hr = pMoniker->BindToObject(NULL,NULL,IID_IBaseFilter,(void**)&pFilter);
break;
}
}
pProperty->Release();
pMoniker->Release();
}
pEnumMoniker->Release();
return pFilter;
}
{
::CoInitialize(NULL);
// IID myroupName = CLSID_SystemDeviceEnum;
IID myroupName = CLSID_LegacyAmFilterCategory;
IBaseFilter* pFilter = this->FindFilterByClsId(myroupName,"Video Renderer");
int i=0;
}
IBaseFilter* CCaremaDlg::FindFilterByClsId(IID Typeid, CString comName)
{
ICreateDevEnum* pAllDevSource = NULL;
IBaseFilter* pFilter = NULL;
HRESULT hr = ::CoCreateInstance(CLSID_SystemDeviceEnum,NULL,CLSCTX_INPROC_SERVER,IID_ICreateDevEnum,(void**)&pAllDevSource);
if(FAILED(hr)){
MessageBox("Faild!");
}
MessageBox("Success!");
//找出了系统设备
IEnumMoniker* pEnumMoniker = NULL;
ULONG dsize = 0;
hr = pAllDevSource->CreateClassEnumerator(Typeid,&pEnumMoniker,0);
if( hr != S_OK ){
MessageBox("IEnumMoniker Faild!");
}
MessageBox("IEnumMoniker Success!");
IMoniker* pMoniker = NULL;
while( pEnumMoniker->Next(1,&pMoniker,&dsize)==S_OK )
{
IPropertyBag* pProperty = NULL;
if( SUCCEEDED(pMoniker->BindToStorage(NULL,NULL,IID_IPropertyBag,(void**)&pProperty)) )
{
VARIANT DevName;
VariantInit(&DevName);
DevName.vt = VT_BSTR;
pProperty->Read( L"Friendlyname", &DevName, 0 );
CString str(DevName.bstrVal);
VariantClear(&DevName);
MessageBox(str);
if( str == comName )
{
hr = pMoniker->BindToObject(NULL,NULL,IID_IBaseFilter,(void**)&pFilter);
break;
}
}
pProperty->Release();
pMoniker->Release();
}
pEnumMoniker->Release();
return pFilter;
}