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


C++ IPropertyBag类代码示例

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


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

示例1: CoCreateInstance

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

示例2: 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

示例3: OutputDebug

HRESULT CDSFilterEnum::getFriendlyName(wstring* pName)
{
	if (m_pIMoniker == NULL) {
		return E_POINTER;
	}

    IPropertyBag *pBag;
    HRESULT hr =m_pIMoniker->BindToStorage(NULL, NULL, IID_IPropertyBag, reinterpret_cast<void**>(&pBag));

	if(FAILED(hr)) {
		OutputDebug(L"Cannot BindToStorage for.\n");
        return hr;
    }

	VARIANT varName;
	::VariantInit(&varName);

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

	if(FAILED(hr)){
		OutputDebug(L"IPropertyBag->Read method failed for.\n");
		SAFE_RELEASE(pBag);
		::VariantClear(&varName);
		return hr;
    }
	
	*pName = varName.bstrVal;
	
	SAFE_RELEASE(pBag);
	::VariantClear(&varName);

	return S_OK;
}
开发者ID:radi-sh,项目名称:BonDriver_BDA,代码行数:33,代码来源:DSFilterEnum.cpp

示例4: while

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: CoCreateInstance

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

示例6: GetI

// @pymethod |PyIPersistPropertyBag|Save|Called by the container to save the object's properties.
PyObject *PyIPersistPropertyBag::Save(PyObject *self, PyObject *args)
{
	PyObject *obBag; // @pyparm <o PyIPropertyBag>|bag||the caller's property bag.
	int clearDirty; // @pyparm int|clearDirty||Specifies whether to clear the dirty flag.
	int saveAllProperties; // @pyparm int|saveProperties||Specifies whether to save all properties or just those that have changed
	if ( !PyArg_ParseTuple(args, "Oii:Save", &obBag, &clearDirty, &saveAllProperties) )
		return NULL;

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

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

	PY_INTERFACE_PRECALL;
	HRESULT hr = pIPPB->Save(pIPB, clearDirty, saveAllProperties);
	pIPB->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIPPB, IID_IPersistPropertyBag);

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

示例7: while

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

示例8: GetI

// @pymethod |PyIPropertyBag|Write|Called by the control to write each property in turn to the storage provided by the container.
PyObject *PyIPropertyBag::Write(PyObject *self, PyObject *args)
{
	PyObject *obName;
	PyObject *obValue;
	// @pyparm str|propName||Name of the property to read.
	// @pyparm object|value||The value for the property.  The value must be able to be converted to a COM VARIANT.
	if ( !PyArg_ParseTuple(args, "OO:Write", &obName, &obValue) )
		return NULL;

	IPropertyBag *pIPB = GetI(self);
	if ( pIPB == NULL )
		return NULL;

	TmpWCHAR Name;
	if ( !PyWinObject_AsWCHAR(obName, &Name))
		return NULL;
	VARIANT var;
	if ( !PyCom_VariantFromPyObject(obValue, &var) )
		return NULL;

	PY_INTERFACE_PRECALL;
	HRESULT hr = pIPB->Write(Name, &var);
	VariantClear(&var);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIPB, IID_IPropertyBag);

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

示例9: CoInitialize

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

示例10: defined

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

示例11: QVideoDeviceControl

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

示例12: printf

HRESULT STDMETHODCALLTYPE UIDelegate::exceededDatabaseQuota( 
        /* [in] */ IWebView *sender,
        /* [in] */ IWebFrame *frame,
        /* [in] */ IWebSecurityOrigin *origin,
        /* [in] */ BSTR databaseIdentifier)
{
    BSTR protocol;
    BSTR host;
    unsigned short port;

    origin->protocol(&protocol);
    origin->host(&host);
    origin->port(&port);

    if (!done && gTestRunner->dumpDatabaseCallbacks())
        printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%S, %S, %i} database:%S\n", protocol, host, port, databaseIdentifier);

    SysFreeString(protocol);
    SysFreeString(host);

    unsigned long long defaultQuota = 5 * 1024 * 1024;
    double testDefaultQuota = gTestRunner->databaseDefaultQuota();
    if (testDefaultQuota >= 0)
        defaultQuota = testDefaultQuota;

    COMPtr<IWebDatabaseManager> databaseManager;
    COMPtr<IWebDatabaseManager> tmpDatabaseManager;

    if (FAILED(WebKitCreateInstance(CLSID_WebDatabaseManager, 0, IID_IWebDatabaseManager, (void**)&tmpDatabaseManager))) {
        origin->setQuota(defaultQuota);
        return S_OK;
    }
    if (FAILED(tmpDatabaseManager->sharedWebDatabaseManager(&databaseManager))) {
        origin->setQuota(defaultQuota);
        return S_OK;
    }
    IPropertyBag* detailsBag;
    if (FAILED(databaseManager->detailsForDatabase(databaseIdentifier, origin, &detailsBag))) {
        origin->setQuota(defaultQuota);
        return S_OK;
    }
    VARIANT var;
    detailsBag->Read(WebDatabaseUsageKey, &var, 0);
    unsigned long long expectedSize = V_UI8(&var);
    unsigned long long newQuota = defaultQuota;

    double maxQuota = gTestRunner->databaseMaxQuota();
    if (maxQuota >= 0) {
        if (defaultQuota < expectedSize && expectedSize <= maxQuota) {
            newQuota = expectedSize;
            printf("UI DELEGATE DATABASE CALLBACK: increased quota to %llu\n", newQuota);
        }
    }
    origin->setQuota(newQuota);

    return S_OK;
}
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:57,代码来源:UIDelegate.cpp

示例13: CoCreateInstance

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: CoCreateInstance

//枚举设备
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: CoCreateInstance

//连接音频设备,并将音频设备加入到
BOOL CCaptureAudio::BindToAudioDev(int deviceId, IBaseFilter **pFilter)
{
	if (deviceId < 0)
	{
		return FALSE;
	}
	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_AudioInputDeviceCategory,&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);
					//m_iDeviceId = deviceId;
				}
				SysFreeString(var.bstrVal);
			}
			pBag->Release();
		}
		pM->Release();
		index++;
	}
	return TRUE;
}
开发者ID:9crk,项目名称:EasyClient,代码行数:52,代码来源:CaptureAudio.cpp


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