EnumFilterDlg.cpp
上传用户:sztlpcb
上传日期:2007-06-09
资源大小:741k
文件大小:4k
- // EnumFilterDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ccd.h"
- #include "EnumFilterDlg.h"
- #include <dshow.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CEnumFilterDlg dialog
- CEnumFilterDlg::CEnumFilterDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CEnumFilterDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CEnumFilterDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CEnumFilterDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CEnumFilterDlg)
- DDX_Control(pDX, IDC_TREE, m_TreeCtrl);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CEnumFilterDlg, CDialog)
- //{{AFX_MSG_MAP(CEnumFilterDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CEnumFilterDlg message handlers
- // Purpose:Enum Filters
- //
- // Param: None
- //
- // ret: None
- //
- // Create List : LaiLee 2001/10
- // Modify List :
- BOOL CEnumFilterDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- // TODO: Add extra initialization here
- CoInitialize(NULL);
- static char *lpszCat[]={_T("CLSID_AudioInputDeviceCategory"),
- _T("CLSID_AudioCompressorCategory"),
- _T("CLSID_AudioRendererCategory"),
- _T("CLSID_LegacyAmFilterCategory"),
- _T("CLSID_MidiRendererCategory"),
- _T("CLSID_VideoInputDeviceCategory"),
- _T("CLSID_VideoCompressorCategory"),
- _T("CLSID_ActiveMovieCategories")};
- static char szBuf[128];
- ICreateDevEnum *pSysDevEnum = NULL;
- IEnumMoniker *pEnumCat = NULL;
- IMoniker *pMoniker;
- ULONG cFetched;
- IPropertyBag *pPropBag;
- VARIANT varName;
- TV_INSERTSTRUCT tv;
- HTREEITEM htItem;
- for(int nC1=0;nC1<8;nC1++)
- {
- tv.hParent=NULL;
- tv.hInsertAfter=TVI_LAST;
- tv.item.mask=TVIF_TEXT;
- tv.item.pszText = lpszCat[nC1];
- htItem=this->m_TreeCtrl.InsertItem(&tv);
- CoCreateInstance(CLSID_SystemDeviceEnum,
- NULL, CLSCTX_INPROC, IID_ICreateDevEnum,
- (void **)&pSysDevEnum);
- switch(nC1)
- {
- case 0:
- pSysDevEnum->CreateClassEnumerator(CLSID_AudioInputDeviceCategory, &pEnumCat, 0);
- break;
- case 1:
- pSysDevEnum->CreateClassEnumerator(CLSID_AudioCompressorCategory, &pEnumCat, 0);
- break;
- case 2:
- pSysDevEnum->CreateClassEnumerator(CLSID_AudioRendererCategory, &pEnumCat, 0);
- break;
- case 3:
- pSysDevEnum->CreateClassEnumerator(CLSID_LegacyAmFilterCategory, &pEnumCat, 0);
- break;
- case 4:
- pSysDevEnum->CreateClassEnumerator(CLSID_MidiRendererCategory, &pEnumCat, 0);
- break;
- case 5:
- pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
- break;
- case 6:
- pSysDevEnum->CreateClassEnumerator(CLSID_VideoCompressorCategory, &pEnumCat, 0);
- break;
- case 7:
- pSysDevEnum->CreateClassEnumerator(CLSID_ActiveMovieCategories, &pEnumCat, 0);
- break;
- default:
- break;
- }
-
- if(pEnumCat!=NULL)
- {
- while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
- {
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
- // Retreive Filter's Name
- varName.vt = VT_BSTR;
- pPropBag->Read(L"FriendlyName", &varName, 0);
-
- tv.hParent=htItem;
- tv.hInsertAfter=TVI_LAST;
- tv.item.mask=TVIF_TEXT;
-
- ::wcstombs(szBuf,varName.bstrVal,128);
- tv.item.pszText =szBuf;
-
- //Insert Filter Info to TreeControl
- this->m_TreeCtrl.InsertItem(&tv);
- SysFreeString(varName.bstrVal);
- pPropBag->Release();
- pMoniker->Release();
- }
- pEnumCat->Release();
- }
- pSysDevEnum->Release();
- }
-
- return TRUE;
-
- }