当前位置: 首页>>代码示例>>C++>>正文


C++ IPropertyBag::Release方法代码示例

本文整理汇总了C++中IPropertyBag::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IPropertyBag::Release方法的具体用法?C++ IPropertyBag::Release怎么用?C++ IPropertyBag::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPropertyBag的用法示例。


在下文中一共展示了IPropertyBag::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PyCom_BuildPyException

// @pymethod |PyIPersistPropertyBag|Load|Called by the container to load the control's properties.
PyObject *PyIPersistPropertyBag::Load(PyObject *self, PyObject *args)
{
	PyObject *obBag; // @pyparm <o PyIPropertyBag>|bag||the caller's property bag.
	PyObject *obLog = NULL; // @pyparm <o PyIErrorLog>|log|None|the caller's error log, or None
	if ( !PyArg_ParseTuple(args, "O|O:Load", &obBag, &obLog) )
		return NULL;

	IPersistPropertyBag *pIPPB = GetI(self);
	if ( pIPPB == NULL )
		return NULL;

	IPropertyBag *pIPB;
	if ( !PyCom_InterfaceFromPyObject(obBag, IID_IPropertyBag, (LPVOID*)&pIPB, FALSE) )
		return NULL;

	IErrorLog *pIEL = NULL;
	if ( obLog != NULL && obLog != Py_None &&
		 !PyCom_InterfaceFromPyObject(obLog, IID_IErrorLog, (LPVOID*)&pIEL, FALSE) )
	{
		pIPB->Release();
		return NULL;
	}

	PY_INTERFACE_PRECALL;
	HRESULT hr = pIPPB->Load(pIPB, pIEL);
	pIPB->Release();
	pIEL->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIPPB, IID_IPersistPropertyBag);

	Py_INCREF(Py_None);
	return Py_None;
}
开发者ID:DavidGuben,项目名称:rcbplayspokemon,代码行数:35,代码来源:PyIPersistPropertyBag.cpp

示例2: FindCaptureDevice

HRESULT VideoCapture::FindCaptureDevice(const wchar_t* deviceName, IBaseFilter** ppSrcFilter)
{
        ICreateDevEnum *pSysDevEnum = NULL;
        hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
                              IID_ICreateDevEnum, (void **)&pSysDevEnum);
        if (FAILED(hr)) 
                return hr;        

        // Obtain a class enumerator for the video input devices category.
        IEnumMoniker *pEnumCat = NULL;
        hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
        if (hr == S_OK) {
                // Enumerate the monikers.
                IMoniker *pMoniker = NULL;
                ULONG cFetched;
                while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) {
                        IPropertyBag *pPropBag;
                        hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag,
                                                     (void **)&pPropBag);
                        if (SUCCEEDED(hr)) {
                                // To retrieve the filter's friendly name
                                VARIANT varName;
                                VariantInit(&varName);
                                hr = pPropBag->Read(L"FriendlyName", &varName, 0);
                                if (SUCCEEDED(hr)) {
                                        if (wcscmp(deviceName, varName.bstrVal) == 0) {
                                                m_DeviceName = varName.bstrVal;
                                                VariantClear(&varName);    

                                                IBaseFilter* pFilter;
                                                hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter,
                                                                            (void**)&pFilter);
                                                if (SUCCEEDED(hr)) {
                                                        *ppSrcFilter = pFilter;
                                                        (*ppSrcFilter)->AddRef();
                                                        pFilter->Release();
                                                }
                                                
                                                pPropBag->Release();        
                                                pMoniker->Release();
                                                pEnumCat->Release();
                                                pSysDevEnum->Release();
                                                return hr;
                                        }                                        
                                }
                                VariantClear(&varName);                                
                                pPropBag->Release();
                        }
                        pMoniker->Release();
                }
                pEnumCat->Release();
        }
        else {
                pSysDevEnum->Release(); 
                return hr;
        }

        pSysDevEnum->Release();
        return -1;        
}
开发者ID:dunghand,项目名称:msrds,代码行数:60,代码来源:VideoCapture.cpp

示例3: EnumDevices

int CCaptureVideo::EnumDevices(CArray<CString, CString>& arList)
{
	int nCount = 0;
	//枚举视频扑捉设备
	ICreateDevEnum *pCreateDevEnum;

	HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,IID_ICreateDevEnum, (void**)&pCreateDevEnum);
	
	if (hr != NOERROR)return -1;
	
	CComPtr<IEnumMoniker> pEm;
	
	hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,&pEm, 0);
	
	if (hr != NOERROR)return -1;
	
	pEm->Reset();
	
	ULONG cFetched;
	
	IMoniker *pM;
	
	while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK)
	{
		IPropertyBag *pBag;

		hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);

		if(SUCCEEDED(hr)) 
		{
			VARIANT var;

			var.vt = VT_BSTR;

			hr = pBag->Read(L"FriendlyName", &var, NULL);

			if (hr == NOERROR) 
			{
				char szStr[2048];

				nCount++;

				WideCharToMultiByte(CP_ACP,0,var.bstrVal, -1, szStr, 2048, NULL, NULL);
				
				arList.Add( CString(szStr) );
				
				SysFreeString(var.bstrVal);
				
				pM->AddRef();

			}

			pBag->Release();
		}

		pM->Release();
	}

	return nCount;
}
开发者ID:layerfsd,项目名称:PersonalIBA,代码行数:60,代码来源:CaptureVideo.cpp

示例4: GetAudioDevices

HRESULT CaptureDevices::GetAudioDevices(vector<wstring> *audioDevices)
{
	if (!enumMonikerAudio)
		return E_FAIL;

	IMoniker *pMoniker = NULL;
	wstring name;

	while (enumMonikerAudio->Next(1, &pMoniker, NULL) == S_OK)
	{
		IPropertyBag *pPropBag;
		HRESULT hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
		if (FAILED(hr))
		{
			pMoniker->Release();
			continue;  
		} 

		VARIANT var;
		VariantInit(&var);

		hr = pPropBag->Read(L"FriendlyName", &var, 0);
		if (SUCCEEDED(hr))
		{
			name = var.bstrVal;
			VariantClear(&var); 
		}

		pPropBag->Release();
		pMoniker->Release();

		if (!name.empty())
			audioDevices->push_back(name);
	}
}
开发者ID:byteman,项目名称:record,代码行数:35,代码来源:CaptureDevices.cpp

示例5: GetDSFiltersNames

//Возвращает массив имен зарегистрированных в системе фильтров DirectShow (определенной категории)
//Что бы узнать требуемую размерность массива, достаточно вызвать функцию
//с lpwDSFilArr равным NULL - значение вернется в pArrSize.
//В случае ошибки функция вернет значение меньше нуля
int CDirectShow::GetDSFiltersNames(LPWSTR *lpwDSFilArr, LPDWORD pArrSize, DWORD dwBuffSize)
{
	if (!m_lDSFilCount) return -1;
	if (lpwDSFilArr)
	{
		IPropertyBag *pPropBag = NULL;
		VARIANT varDSFName = { 0 };
		varDSFName.vt = VT_BSTR;
		for (m_lCounter = 0; m_lCounter < m_lDSFilCount; m_lCounter++)
		{
			if (m_pDSFMoniker[m_lCounter] == NULL) return -1;
			m_pDSFMoniker[m_lCounter]->BindToStorage(NULL, NULL, IID_IPropertyBag, (LPVOID *)&pPropBag);
			if (SUCCEEDED(pPropBag->Read(L"FriendlyName", &varDSFName, NULL)))
			{
				wcscpy(lpwDSFilArr[m_lCounter], varDSFName.bstrVal);
				SysFreeString(varDSFName.bstrVal);
			}
			else
			{
				wcscpy(lpwDSFilArr[m_lCounter], L"<untitled>");
			}
			pPropBag->Release();
		}
		return 0;
	}
	else
	{
		*pArrSize = m_lDSFilCount;
		return 0;
	}
}
开发者ID:BorisVorontsov,项目名称:easybar,代码行数:35,代码来源:DirectShow.cpp

示例6: FindFilter

bool CDirectShowFilterFinder::FindFilter(const GUID *pInTypes,int InTypeCount,
	const GUID *pOutTypes,int OutTypeCount,DWORD Merit)
{
	// フィルタを検索する
	bool bRet = false;
	IFilterMapper2 *pMapper=NULL;
	HRESULT hr=::CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC, IID_IFilterMapper2, (void **)&pMapper);

	if (SUCCEEDED(hr)) {
		IEnumMoniker *pEnum=NULL;

		hr = pMapper->EnumMatchingFilters(
			&pEnum,
			0,					// 予約済み
			TRUE,				// 完全一致を使用するか
			Merit,				// 最小のメリット
			TRUE,				// 1 つ以上の入力ピンか?
			InTypeCount,		// 入力のメジャータイプ/サブタイプの対の数
			pInTypes,			// 入力のメジャータイプ/サブタイプの対の配列
			NULL,				// 入力メディア
			NULL,				// 入力ピンのカテゴリ
			FALSE,				// レンダラでなければならないか
			TRUE,				// 1 つ以上の出力ピンか
			OutTypeCount,		// 出力のメジャータイプ/サブタイプの対の数
			pOutTypes,			// 出力のメジャータイプ/サブタイプの対の配列
			NULL,				// 出力メディア
			NULL);				// 出力ピンのカテゴリ
		if (SUCCEEDED(hr)) {
			IMoniker *pMoniker;
			ULONG cFetched;
			while (pEnum->Next(1, &pMoniker, &cFetched) == S_OK) {
				IPropertyBag *pPropBag;
				hr=pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
				if (SUCCEEDED(hr)) {
					VARIANT varName,varID;
					::VariantInit(&varName);
					::VariantInit(&varID);
					hr=pPropBag->Read(L"FriendlyName", &varName, 0);
					if (SUCCEEDED(hr)) {
						hr=pPropBag->Read(L"CLSID", &varID, 0);
						if (SUCCEEDED(hr)) {
							bRet = true;
							CFilterInfo FilterInfo;
							FilterInfo.SetFriendlyName(varName.bstrVal);
							::CLSIDFromString(varID.bstrVal,&FilterInfo.m_clsid);
							m_FilterList.push_back(FilterInfo);
							::SysFreeString(varID.bstrVal);
						}
						SysFreeString(varName.bstrVal);
					}
					pPropBag->Release();
				}
				pMoniker->Release();
			}
			pEnum->Release();
		}
		pMapper->Release();
	}
	return bRet;
}
开发者ID:ACUVE,项目名称:TVTest,代码行数:60,代码来源:DirectShowUtil.cpp

示例7: AddDSFilterToFilterGraph

//Добавляет фильтр DirectShow в Filter Graph
//Перед вызовом этой функции необходимо вызвать UpdateDSFiltersArray(...) (если она не вызывалась)
//В случае ошибки функция вернет значение меньше нуля
int CDirectShow::AddDSFilterToFilterGraph(LPCWSTR lpwDSFilName)
{
	if (!m_pGraphBuilder) return -1;
	if (!m_lDSFilCount) return -1;
	IPropertyBag *pPropBag = NULL;
	VARIANT varDSFName = { 0 };
	varDSFName.vt = VT_BSTR;
	IBaseFilter *pDSFilter = NULL;
	for (m_lCounter = 0; m_lCounter < m_lDSFilCount; m_lCounter++)
	{
		m_pDSFMoniker[m_lCounter]->BindToStorage(NULL, NULL, IID_IPropertyBag, (LPVOID *)&pPropBag);
		if (FAILED(pPropBag->Read(L"FriendlyName", &varDSFName, NULL)))
		{
			if (m_lCounter >= (m_lDSFilCount - 1))
			{
				pPropBag->Release();
				return -1;
			} else continue;
		}
		if (_wcsicmp(lpwDSFilName, varDSFName.bstrVal) == 0)
		{
			if (FAILED(m_pDSFMoniker[m_lCounter]->BindToObject(NULL, NULL, IID_IBaseFilter,
				(LPVOID*)&pDSFilter)))
			{
				SysFreeString(varDSFName.bstrVal);
				pPropBag->Release();
				return -1;
			}
			m_pGraphBuilder->AddFilter(pDSFilter, varDSFName.bstrVal);
			SysFreeString(varDSFName.bstrVal);
			pPropBag->Release();
			break;
		}
		else
		{
			if (m_lCounter >= (m_lDSFilCount - 1))
			{
				SysFreeString(varDSFName.bstrVal);
				pPropBag->Release();
				return -1;
			}
		}
		SysFreeString(varDSFName.bstrVal);
		pPropBag->Release();
	}
	return 0;
}
开发者ID:BorisVorontsov,项目名称:easybar,代码行数:50,代码来源:DirectShow.cpp

示例8: BindFilter

bool CCaptureVideo::BindFilter(int deviceId, IBaseFilter **pFilter)
{
	if (deviceId < 0) return false;

	// enumerate all video capture devices
	CComPtr<ICreateDevEnum> pCreateDevEnum;

	HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
	IID_ICreateDevEnum, (void**)&pCreateDevEnum);

	if (hr != NOERROR) return false;

	CComPtr<IEnumMoniker> pEm;

	hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,&pEm, 0);

	if (hr != NOERROR) return false;

	pEm->Reset();

	ULONG cFetched;

	IMoniker* pM;

	int index = 0;

	while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK, index <= deviceId)
	{
		IPropertyBag* pBag;

		hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);

		if(SUCCEEDED(hr)) 
		{
			VARIANT var;

			var.vt = VT_BSTR;

			hr = pBag->Read(L"FriendlyName", &var, NULL);

			if (hr == NOERROR) 
			{
				if (index == deviceId)
				{
					pM->BindToObject(0, 0, IID_IBaseFilter, (void**)pFilter);
				}
				SysFreeString(var.bstrVal);
			}

			pBag->Release();

		}

		pM->Release();

		index++;
	}
	return true;
}
开发者ID:layerfsd,项目名称:PersonalIBA,代码行数:59,代码来源:CaptureVideo.cpp

示例9: LogDeviceInformation

void Audio::LogDeviceInformation(IEnumMoniker *pEnum)
{
	logger.addline("Starting to record audio or video input devices.", info);
	IMoniker *pMoniker = NULL;

	while (pEnum->Next(1, &pMoniker, NULL) == S_OK)
	{
		logger.addline("Have found a new device", success);
		IPropertyBag *pPropBag;
		HRESULT hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
		if (FAILED(hr))
		{
			pMoniker->Release();
			continue;
		}

		VARIANT var;
		VariantInit(&var);

		// Get description or friendly name.
		hr = pPropBag->Read(L"Description", &var, 0);
		if (FAILED(hr))
		{
			hr = pPropBag->Read(L"FriendlyName", &var, 0);
		}
		if (SUCCEEDED(hr))
		{
			//printf("%S\n", var.bstrVal);
			logger.addline("Below is the device name.", debug);
			logger.addline(ConvertBSTRToMBS(var.bstrVal), debug);
			VariantClear(&var);
		}

		hr = pPropBag->Write(L"FriendlyName", &var);

		// WaveInID applies only to audio capture devices.
		hr = pPropBag->Read(L"WaveInID", &var, 0);
		if (SUCCEEDED(hr))
		{
			//printf("WaveIn ID: %d\n", var.lVal);
			logger.addline("Below is the WaveIn ID.", debug);
			logger.addline("BLANK FOR NOW! FIX ME LATER", debug);
			VariantClear(&var);
		}

		hr = pPropBag->Read(L"DevicePath", &var, 0);
		if (SUCCEEDED(hr))
		{
			// The device path is not intended for display.
			printf("Device path: %S\n", var.bstrVal);
			logger.addline("Below is the device path.", debug);
			//logger.addline(ConvertBSTRToMBS(var.bstrVal), success);
			VariantClear(&var);
		}

		pPropBag->Release();
		pMoniker->Release();
	}
}
开发者ID:TahaAbbasi-Hashemi,项目名称:TLog-Library-,代码行数:59,代码来源:Audio.cpp

示例10: EnumDevices

int Camera::EnumDevices(PENUMDEVICE pCallback, void* pItem)
{
	int nDevice = 0;
	HRESULT			hr				= S_OK;

	// System device enumerators
	ICreateDevEnum	*pDevEnum		= NULL;
	IEnumMoniker	*pEnum			= NULL;
	IMoniker		*pMoniker		= NULL;

	CoInitialize(NULL);

	// Create system device enumerator
	hr = CoCreateInstance( CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, reinterpret_cast<void**>(&pDevEnum) );
	if (FAILED(hr)) {
		return 0;
	}

	// create enumerator for video capture devices
	hr = pDevEnum->CreateClassEnumerator( CLSID_VideoInputDeviceCategory, &pEnum, 0 );
	if (SUCCEEDED(hr)) 
	{
		IBindCtx* pbcfull = NULL;

		// Enumerate through the devices and print friendly name
		while ( (pEnum->Next( 1, &pMoniker, NULL ) == S_OK))
		{	
			VARIANT var;
			IPropertyBag *pPropertyBag;
			char szCameraName[200];

			// FrienlyName : The name of the device
			var.vt = VT_BSTR;

			// Bind to IPropertyBag
			pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropertyBag);
			
			// Reference: https://msdn.microsoft.com/en-us/library/windows/desktop/dd377566(v=vs.85).aspx
			hr = pPropertyBag->Read(L"Description", &var, 0);	// "FriendlyName", "DevicePath", "Description"
			if (FAILED(hr))
			{
				pPropertyBag->Read(L"FriendlyName", &var, 0);
			}
			WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1,szCameraName, sizeof(szCameraName), 0, 0);
			if (pCallback != NULL) {
				(*pCallback)(pItem, szCameraName);
			}
			VariantClear(&var);

			// Release resource
			pPropertyBag->Release();

			nDevice++;

			SAFE_RELEASE( pMoniker );
		}
	}
	return nDevice; // returns count of camera
}
开发者ID:Juedy,项目名称:Camera,代码行数:59,代码来源:Camera.cpp

示例11: GetCameraNameDX

void FaceTrackNoIR::GetCameraNameDX() {
#if defined(_WIN32)
	ui.cameraName->setText("No video-capturing device was found in your system: check if it's connected!");

	// Create the System Device Enumerator.
	HRESULT hr;
	ICreateDevEnum *pSysDevEnum = NULL;
	hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);
	if (FAILED(hr))
	{
		qDebug() << "GetWDM says: CoCreateInstance Failed!";
		return;
	}

	qDebug() << "GetWDM says: CoCreateInstance succeeded!";
	
	// Obtain a class enumerator for the video compressor category.
	IEnumMoniker *pEnumCat = NULL;
	hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);

	if (hr == S_OK) {
		qDebug() << "GetWDM says: CreateClassEnumerator succeeded!";

		IMoniker *pMoniker = NULL;
		ULONG cFetched;
		if (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) {
			IPropertyBag *pPropBag;
			hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
			if (SUCCEEDED(hr))	{
				VARIANT varName;
				VariantInit(&varName);
				hr = pPropBag->Read(L"FriendlyName", &varName, 0);
				if (SUCCEEDED(hr))
				{
					QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal));
					qDebug() << "GetWDM says: Moniker found:" << str;
					ui.cameraName->setText(str);
				}
				VariantClear(&varName);

				pPropBag->Release();
			}
			pMoniker->Release();
		}
		pEnumCat->Release();
	}
	pSysDevEnum->Release();
#else
    for (int i = 0; i < 16; i++) {
        char buf[128];
        sprintf(buf, "/dev/video%d", i);
        if (access(buf, R_OK | W_OK) == 0) {
            ui.cameraName->setText(QString(buf));
            break;
        }
    }
#endif
}
开发者ID:vheathen,项目名称:opentrack,代码行数:58,代码来源:facetracknoir.cpp

示例12: temp

QT_BEGIN_NAMESPACE

DSVideoDeviceControl::DSVideoDeviceControl(QObject *parent)
    : QVideoDeviceControl(parent)
{
    m_session = qobject_cast<DSCameraSession*>(parent);

    devices.clear();
    descriptions.clear();

    CoInitialize(NULL);
    ICreateDevEnum* pDevEnum = NULL;
    IEnumMoniker* pEnum = NULL;
    // Create the System device enumerator
    HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
            CLSCTX_INPROC_SERVER, IID_ICreateDevEnum,
            reinterpret_cast<void**>(&pDevEnum));
    if(SUCCEEDED(hr)) {
        // Create the enumerator for the video capture category
        hr = pDevEnum->CreateClassEnumerator(
                CLSID_VideoInputDeviceCategory, &pEnum, 0);
        if (S_OK == hr) {
            pEnum->Reset();
            // go through and find all video capture devices
            IMoniker* pMoniker = NULL;
            while(pEnum->Next(1, &pMoniker, NULL) == S_OK) {
                IPropertyBag *pPropBag;
                hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag,
                        (void**)(&pPropBag));
                if(FAILED(hr)) {
                    pMoniker->Release();
                    continue; // skip this one
                }
                // Find the description
                WCHAR str[120];
                VARIANT varName;
                varName.vt = VT_BSTR;
                hr = pPropBag->Read(L"FriendlyName", &varName, 0);
                if(SUCCEEDED(hr)) {
                    wcsncpy(str, varName.bstrVal, sizeof(str)/sizeof(str[0]));
                    QString temp(QString::fromUtf16((unsigned short*)str));
                    devices.append(QString("ds:%1").arg(temp).toLocal8Bit().constData());
                    hr = pPropBag->Read(L"Description", &varName, 0);
                    wcsncpy(str, varName.bstrVal, sizeof(str)/sizeof(str[0]));
                    QString temp2(QString::fromUtf16((unsigned short*)str));
                    descriptions.append(temp2.toLocal8Bit().constData());
                }
                pPropBag->Release();
                pMoniker->Release();
            }
            pEnum->Release();
        }
        pDevEnum->Release();
    }
    CoUninitialize();

    selected = 0;
}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:58,代码来源:dsvideodevicecontrol.cpp

示例13: EnumDevices

int VideoCapture::EnumDevices()
{
	int id = 0;
	
    // enumerate all video capture devices
	CComPtr<ICreateDevEnum> pCreateDevEnum;

	HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
								  IID_ICreateDevEnum, (void**)&pCreateDevEnum);
    if (hr != NOERROR)  return -1;
	
    CComPtr<IEnumMoniker> pEm;
    hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
								&pEm, 0);
    if (hr != NOERROR) 	return -1 ;
    
    pEm->Reset();

    IMoniker *pM;
	nDevices = 0;
    while(hr = pEm->Next(1, &pM, NULL), hr==S_OK)
		nDevices++;
	
	if (nDevices==0) return -1;

	pEm->Reset();

	devices_names = new string[nDevices];
		
	while(hr = pEm->Next(1, &pM, NULL), hr==S_OK)
    {
		IPropertyBag *pBag;
		hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
		if(SUCCEEDED(hr)) 
		{
			VARIANT var;
			var.vt = VT_BSTR;
			hr = pBag->Read(L"FriendlyName", &var, NULL);
			if (hr == NOERROR) 
			{
				TCHAR str[2048];		

				WideCharToMultiByte(CP_ACP,0,var.bstrVal, -1, str, 2048, NULL, NULL);
				devices_names[id] = str;

				id++;

				SysFreeString(var.bstrVal);
			}
			pBag->Release();
		}
		pM->Release();
    }
	return id;
}
开发者ID:martakuzak,项目名称:ASOD1,代码行数:55,代码来源:VideoCapture.cpp

示例14: EnumDevices

//枚举设备
HRESULT CCaptureDevice::EnumDevices( REFCLSID clsidDeviceClass, ENUMCALLBACK pEnumCallBack, LPVOID lp )
{
	//创建枚举组件
    ICreateDevEnum *pCreateDevEnum;
	HRESULT hr;
	VARIANT var;
	hr = CoCreateInstance( CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,IID_ICreateDevEnum, (void**)&pCreateDevEnum );
	if( hr==S_OK )
	{
		//创建枚举器
		IEnumMoniker* pEm;
		hr = pCreateDevEnum->CreateClassEnumerator( clsidDeviceClass, &pEm, 0 );
		if( hr==S_OK )
		{
			if( pEm )
			{
				//复位
				pEm->Reset();

				//准备顺序找设备
				ULONG cFetched;
				IMoniker *pM;
				BOOL bCancel = false;
				int index = 0;
				while( !bCancel && (hr = pEm->Next(1, &pM, &cFetched), hr==S_OK) )
				{
					IPropertyBag *pBag;
					hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
					if(hr==S_OK)
					{
						ZeroMemory( &var, sizeof(var) );
						var.vt = VT_BSTR;
						hr = pBag->Read(L"FriendlyName", &var, NULL);
						if(hr==S_OK && var.bstrVal!=0 )
						{
							if(pEnumCallBack)
								hr = pEnumCallBack( index, &var, pM, lp, bCancel );
							SysFreeString(var.bstrVal);
						}
						pBag->Release();
					}
					pM->Release();
					index++;
				}

				//释放
				pEm->Release();
			}
		}
		pCreateDevEnum->Release();
	}
	return hr;
}
开发者ID:duzhi5368,项目名称:FKChessCards,代码行数:54,代码来源:CaptureDevice.cpp

示例15: GetCaptureFilters

HRESULT CaptureGraph::GetCaptureFilters(int *filterCount, CListBox *captureFilterList)
{
	HRESULT hr;
	int maxFilterCount = *filterCount;
	ICreateDevEnum *pSysVideoCaptureEnum = NULL;
	hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysVideoCaptureEnum);
	if (FAILED(hr))
	{
		return hr;
	}
	IBaseFilter *pVideoCapture = NULL;
	IEnumMoniker *pEnumMoniker = NULL;
	hr = pSysVideoCaptureEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumMoniker, 0);
	if (hr == S_OK)
	{
		IMoniker *pMoniker = NULL;
		ULONG fetched;
		int filterIndex = 0;
		while(pEnumMoniker->Next(1, &pMoniker, &fetched) == S_OK)
		{
			IPropertyBag *pPropBag;
			hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
			if(SUCCEEDED(hr))
			{
				VARIANT varName;
				VariantInit(&varName);
				hr = pPropBag->Read(L"FriendlyName", &varName, 0);
				if(SUCCEEDED(hr))
				{
					ASSERT(varName.vt == VT_BSTR);
					CString friendlyName(varName.bstrVal);
					
					VariantClear(&varName);
					pPropBag->Release();

					filterIndex ++;
					captureFilterList->AddString(friendlyName);
					int currentFilterIndex = captureFilterList->FindStringExact(-1, friendlyName);
					captureFilterList->SetItemDataPtr(currentFilterIndex, pMoniker);
					if(filterIndex > maxFilterCount)
					{
						*filterCount = filterIndex;
						break;
					}
				}
			}
		}
		pEnumMoniker->Release();
	}
	pSysVideoCaptureEnum->Release();
}
开发者ID:LeeBn,项目名称:Navigation,代码行数:51,代码来源:CaptureGraph.cpp


注:本文中的IPropertyBag::Release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。