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


C++ IEnumMoniker类代码示例

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


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

示例1: CoCreateInstance

/* 枚举本地系统的采集设备 */
int  CVMR_Capture::EnumDevices(HWND hList)
{
	if (!hList) return  -1;
	int id = 0;
    
	// enumerate all video capture devices
    ICreateDevEnum *pCreateDevEnum;
    HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, 
						CLSCTX_INPROC_SERVER,
						IID_ICreateDevEnum, (void**)&pCreateDevEnum);
    if (hr != NOERROR) return -1;
	
	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) 
			{
				id++;
				(long)SendMessage(hList, CB_ADDSTRING, 0,(LPARAM)var.bstrVal);
				SysFreeString(var.bstrVal);
			}
			pBag->Release();
		}
		pM->Release();
    }
	return id;
}
开发者ID:hiccupzhu,项目名称:misc_starting,代码行数:41,代码来源:VMR_Capture.cpp

示例2: SUCCEEDED

// Code from http://msdn.microsoft.com/en-us/library/windows/desktop/dd377566(v=vs.85).aspx
void	Video::EnumerateDevices( EnumerateDelegate _pDeviceEnumerator, void* _pUserData )
{
	IEnumMoniker*	pEnumerator = NULL;
	ASSERT( SUCCEEDED( EnumerateDevices( CLSID_VideoInputDeviceCategory, &pEnumerator ) ), "Failed enumerating devices!" );

	VARIANT	varFriendlyName, varDevicePath;
	VariantInit( &varFriendlyName );
	VariantInit( &varDevicePath );

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

		// Get friendly name.
		hr = pPropBag->Read( L"FriendlyName", &varFriendlyName, 0 );
		if ( !SUCCEEDED(hr) )
			continue;

		hr = pPropBag->Read( L"DevicePath", &varDevicePath, 0 );
		if ( !SUCCEEDED(hr) )
			continue;

		// Notify delegate
		(*_pDeviceEnumerator)( DeviceIndex++, varFriendlyName.bstrVal, varDevicePath.bstrVal, pMoniker, _pUserData );

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

	pEnumerator->Release();
}
开发者ID:Samana,项目名称:GodComplex,代码行数:40,代码来源:Video.cpp

示例3: EnumDSF

void EnumDSF(void)
{
	ICreateDevEnum *pCreateDevEnum;
	IEnumMoniker *pEnumMoniker;
	IMoniker *pMoniker;
	ULONG nFetched;
	char buf[256];

	CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (PVOID *)&pCreateDevEnum);

	if (pCreateDevEnum->CreateClassEnumerator(CLSID_VideoCompressorCategory, &pEnumMoniker, 0) != S_OK)
	{
		pCreateDevEnum->Release();
		return;
	}

	pEnumMoniker->Reset();

	while (pEnumMoniker->Next(1, &pMoniker, &nFetched) == S_OK)
	{
		IPropertyBag *pPropertyBag;
		VARIANT varFriendlyName;
		WCHAR *pwszDisplayName;

		pMoniker->GetDisplayName(NULL, NULL, &pwszDisplayName);
		varFriendlyName.vt = VT_BSTR;
		pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropertyBag);
		pPropertyBag->Read(L"FriendlyName", &varFriendlyName, 0);
		wsprintf(buf, "DSF\t1\t%S\t%S\n", varFriendlyName.bstrVal, pwszDisplayName);
		printf("%s", buf);
		VariantClear(&varFriendlyName);
		CoTaskMemFree(pwszDisplayName);
		pPropertyBag->Release();
		pMoniker->Release();
	}

	pEnumMoniker->Release();
	pCreateDevEnum->Release();
}
开发者ID:umezawatakeshi,项目名称:vclist,代码行数:39,代码来源:vclist-enum.cpp

示例4: Device_Read

IMoniker* Device_Read(ICreateDevEnum* pDeviceEnum,IMoniker *pDeviceMonik,GUID DEVICE_CLSID,BSTR bstrDeviceName)
{
	HRESULT hr;
	IEnumMoniker *pEnumCat = NULL;// Device enumeration moniker
	VARIANT varName;

	hr = pDeviceEnum->CreateClassEnumerator(DEVICE_CLSID, &pEnumCat, 0);// Enumerate the specified device, distinguished by DEVICE_CLSID

	if (hr == S_OK) 
	{
    ULONG cFetched;
	while (pEnumCat->Next(1, &pDeviceMonik, &cFetched) == S_OK)//Pickup as moniker
	{
        IPropertyBag *pPropBag = NULL;
        hr = pDeviceMonik->BindToStorage(0, 0, IID_IPropertyBag,(void **)&pPropBag);//bind the properties of the moniker
        if (SUCCEEDED(hr))
        {
			VariantInit(&varName);// Initialise the variant data type
			hr = pPropBag->Read(L"FriendlyName", &varName, 0);
      		if (SUCCEEDED(hr))
            {	
				if(Bstr_Compare(varName.bstrVal,bstrDeviceName) == true)//make a comparison
				{	
					wcout<<varName.bstrVal<<" found"<<endl;
					return pDeviceMonik;
				}
			}
			else HR_Failed(hr);
			VariantClear(&varName);//clear the variant data type
			pPropBag->Release();//release the properties
        }
		else HR_Failed(hr);
		pDeviceMonik->Release();//release Device moniker
	}
	pEnumCat->Release();//release category enumerator
	}
	else HR_Failed(hr);
	return NULL;
}
开发者ID:shane-Git,项目名称:NewClassSystem,代码行数:39,代码来源:a3.cpp

示例5: EnumDevice

bool CDirectShowDeviceEnumerator::EnumDevice(REFCLSID clsidDeviceClass)
{
	HRESULT hr;
	ICreateDevEnum *pDevEnum;

	hr=::CoCreateInstance(CLSID_SystemDeviceEnum,NULL,CLSCTX_INPROC_SERVER,
						  IID_ICreateDevEnum,reinterpret_cast<void**>(&pDevEnum));
	if (FAILED(hr))
		return false;

	IEnumMoniker *pEnumCategory;
	hr=pDevEnum->CreateClassEnumerator(clsidDeviceClass,&pEnumCategory,0);
	if (hr==S_OK) {
		IMoniker *pMoniker;
		ULONG cFetched;

		while (pEnumCategory->Next(1,&pMoniker,&cFetched)==S_OK) {
			IPropertyBag *pPropBag;

			hr=pMoniker->BindToStorage(0,0,IID_IPropertyBag,reinterpret_cast<void**>(&pPropBag));
			if (SUCCEEDED(hr)) {
				VARIANT varName;

				::VariantInit(&varName);
				hr=pPropBag->Read(L"FriendlyName",&varName,0);
				if (SUCCEEDED(hr)) {
					m_DeviceList.push_back(CDeviceInfo(varName.bstrVal));
				}
				::VariantClear(&varName);
				pPropBag->Release();
			}
			pMoniker->Release();
		}
		pEnumCategory->Release();
	}
	pDevEnum->Release();
	return true;
}
开发者ID:ACUVE,项目名称:TVTest,代码行数:38,代码来源:DirectShowUtil.cpp

示例6: CoCreateInstance

IBaseFilter *GetAudioDevice (){
	// Create the system device enumerator.
	ICreateDevEnum *pDevEnum = NULL;
	CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, 
		IID_ICreateDevEnum, (void **)&pDevEnum);

	// Create an enumerator for video capture devices.
	IEnumMoniker *pClassEnum = NULL;
	pDevEnum->CreateClassEnumerator(CLSID_AudioInputDeviceCategory, &pClassEnum, 0);

	ULONG cFetched;
	IMoniker *pMoniker = NULL;
	IBaseFilter *pSrc = NULL;
	if (pClassEnum->Next(1, &pMoniker, &cFetched) == S_OK)
	{
	  // Bind the first moniker to a filter object.
	 pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&pSrc);
		pMoniker->Release();
	}
	pClassEnum->Release();
	pDevEnum->Release();
	return pSrc;
}
开发者ID:eaglezhao,项目名称:tracnghiemweb,代码行数:23,代码来源:capturegraphbuilder2.cpp

示例7: eHandler

Camera::Camera(bool Show,bool Start) : eHandler(this),_realData(false),_UpdateWindow(Show),_LastData(0),_CurData(0) {
	DWORD no;
	IGraphBuilder *graph = 0;
	ctrl = 0;
	ICreateDevEnum *devs = 0;
	IEnumMoniker *cams = 0;
	IMoniker *mon = 0;
	IBaseFilter *cam = 0;
	IEnumPins *pins = 0;
	IPin *pin = 0;
	IEnumFilters *fil = 0;
	IBaseFilter *rnd = 0;
	IMemInputPin *mem = 0;
	curCamera = this;
	_isOn = Start;

	CoCreateInstance( CLSID_FilterGraph, 0, CLSCTX_INPROC,IID_IGraphBuilder, (void **)&graph );
	graph->QueryInterface( IID_IMediaControl, (void **)&ctrl );
	CoCreateInstance (CLSID_SystemDeviceEnum, 0, CLSCTX_INPROC, IID_ICreateDevEnum, (void **) &devs);
	devs->CreateClassEnumerator (CLSID_VideoInputDeviceCategory, &cams, 0);
	cams->Next (1,&mon,0);												// get first found capture device (webcam)    
	mon->BindToObject(0,0,IID_IBaseFilter, (void**)&cam);
	
	graph->AddFilter(cam, L"Capture Source");							// add web cam to graph as source
	cam->EnumPins(&pins);												// we need output pin to autogenerate rest of the graph
	pins->Next(1,&pin, 0);												// via graph->Render
	graph->Render(pin);													// graph builder now builds whole filter chain including MJPG decompression on some webcams
	graph->EnumFilters(&fil);											// from all newly added filters
	fil->Next(1,&rnd,0);												// we find last one (renderer)
	rnd->EnumPins(&pins);												// because data we are intersted in are pumped to renderers input pin 
	pins->Next(1,&pin, 0);												// via Receive member of IMemInputPin interface
	pin->QueryInterface(IID_IMemInputPin,(void**)&mem);

	DsHook(mem,6,Receive);												// so we redirect it to our own proc to grab image data

	if (Start) this->Start();
}
开发者ID:si2dharth,项目名称:Windows-Library,代码行数:37,代码来源:Camera.cpp

示例8: GetFilter

IBaseFilter * GetFilter(const char * fname)
{
	HRESULT hr;
	IFilterMapper3 * pFM3;
	hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, 
		IID_IFilterMapper3, (void **)&pFM3);
	
	ICreateDevEnum *pSysDevEnum = NULL;
	hr = pFM3->GetICreateDevEnum(&pSysDevEnum);
	/*
	hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
		IID_ICreateDevEnum, (void **)&pSysDevEnum);
	*/

	if (FAILED(hr))
	{
		return NULL;
	}

	IEnumMoniker *pEnumCat = NULL;
	hr = pSysDevEnum->CreateClassEnumerator(CLSID_LegacyAmFilterCategory, &pEnumCat, 0);
	char str[BUFSIZE_MONIKER_INF];
	IBaseFilter *pFilter = NULL;

	if (hr == S_OK) 
	{
		// Enumerate the monikers.
		IMoniker *pMoniker = NULL;
		ULONG cFetched;
//		cout << "Seeking ffdshow Video Decoder" << endl;
		int ifilter = 0;
		while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK && pFilter == NULL)
		{
			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))
				{
					wcstombs(str, varName.bstrVal, BUFSIZE_MONIKER_INF);
//					cout << ifilter << ":" << str << endl;
					if(strcmp(str, fname) == 0){
						hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter,
							(void**)&pFilter);
					}

				}
				VariantClear(&varName);
				
				pPropBag->Release();
			}
			ifilter++;
			pMoniker->Release();
		}
		pEnumCat->Release();
	}
	pSysDevEnum->Release();
	pFM3->Release();
	return pFilter;
}
开发者ID:d-zenju,项目名称:aws,代码行数:64,代码来源:f_ds_vfile.cpp

示例9: Q_UNUSED

QList<QByteArray> QWindowsAudioDeviceInfo::availableDevices(QAudio::Mode mode)
{
    Q_UNUSED(mode)

    QList<QByteArray> devices;
#ifndef Q_OS_WINCE
    //enumerate device fullnames through directshow api
    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));

    unsigned long iNumDevs = mode == QAudio::AudioOutput ? waveOutGetNumDevs() : waveInGetNumDevs();
    if (SUCCEEDED(hr)) {
        // Create the enumerator for the audio input/output category
        if (pDevEnum->CreateClassEnumerator(
             mode == QAudio::AudioOutput ? CLSID_AudioRendererCategory : CLSID_AudioInputDeviceCategory,
             &pEnum, 0) == S_OK) {
            pEnum->Reset();
            // go through and find all audio devices
            IMoniker *pMoniker = NULL;
            while (pEnum->Next(1, &pMoniker, NULL) == S_OK) {
                IPropertyBag *pPropBag;
                hr = pMoniker->BindToStorage(0,0,IID_IPropertyBag,
                     reinterpret_cast<void **>(&pPropBag));
                if (FAILED(hr)) {
                    pMoniker->Release();
                    continue; // skip this one
                }
                // Find if it is a wave device
                VARIANT var;
                VariantInit(&var);
                hr = pPropBag->Read(mode == QAudio::AudioOutput ? L"WaveOutID" : L"WaveInID", &var, 0);
                if (SUCCEEDED(hr)) {
                    LONG waveID = var.lVal;
                    if (waveID >= 0 && waveID < LONG(iNumDevs)) {
                        VariantClear(&var);
                        // Find the description
                        hr = pPropBag->Read(L"FriendlyName", &var, 0);
                        if (SUCCEEDED(hr)) {
                            QByteArray  device;
                            QDataStream ds(&device, QIODevice::WriteOnly);
                            ds << quint32(waveID) << QString::fromWCharArray(var.bstrVal);
                            devices.append(device);
                        }
                    }
                }

                pPropBag->Release();
                pMoniker->Release();
            }
        }
    }
    CoUninitialize();
#else // Q_OS_WINCE
    if (mode == QAudio::AudioOutput) {
        WAVEOUTCAPS woc;
        unsigned long iNumDevs,i;
        iNumDevs = waveOutGetNumDevs();
        for (i=0;i<iNumDevs;i++) {
            if (waveOutGetDevCaps(i, &woc, sizeof(WAVEOUTCAPS))
                == MMSYSERR_NOERROR) {
                QByteArray  device;
                QDataStream ds(&device, QIODevice::WriteOnly);
                ds << quint32(i) << QString::fromWCharArray(woc.szPname);
                devices.append(device);
            }
        }
    } else {
        WAVEINCAPS woc;
        unsigned long iNumDevs,i;
        iNumDevs = waveInGetNumDevs();
        for (i=0;i<iNumDevs;i++) {
            if (waveInGetDevCaps(i, &woc, sizeof(WAVEINCAPS))
                == MMSYSERR_NOERROR) {
                QByteArray  device;
                QDataStream ds(&device, QIODevice::WriteOnly);
                ds << quint32(i) << QString::fromWCharArray(woc.szPname);
                devices.append(device);
            }
        }
    }
#endif // !Q_OS_WINCE

    return devices;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:89,代码来源:qwindowsaudiodeviceinfo.cpp

示例10: enum_devices

/*
 * Enumerate all video devices
 *
 * See also:
 *
 * Using the System Device Enumerator:
 *     http://msdn2.microsoft.com/en-us/library/ms787871.aspx
 */
int enum_devices()
{
	HRESULT hr;

	printf("Enumerating video input devices ...\n");

	// Create the System Device Enumerator.
	ICreateDevEnum *pSysDevEnum = NULL;
	hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
		IID_ICreateDevEnum, (void **)&pSysDevEnum);
	if(FAILED(hr))
	{
		fprintf(stderr, "ERROR: Unable to create system device enumerator.\n");
		return hr;
	}

	// Obtain a class enumerator for the video input device 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, do the following:
				VARIANT varName;
				VariantInit(&varName);
				hr = pPropBag->Read(L"FriendlyName", &varName, 0);
				if (SUCCEEDED(hr))
				{
					// Display the name in your UI somehow.
					wprintf(L"  Found device: %s\n", varName.bstrVal);
				}
				VariantClear(&varName);

				// To create an instance of the filter, do the following:
				IBaseFilter *pFilter;
				hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter,
					(void**)&pFilter);
				
				process_filter(pFilter);

				//Remember to release pFilter later.
				pPropBag->Release();

			}
			pMoniker->Release();
		}
		pEnumCat->Release();
	}
	pSysDevEnum->Release();

	return 0;
}
开发者ID:7m4mon,项目名称:Q200_PTR,代码行数:70,代码来源:main.cpp

示例11: OnButtonSearch

void MainDialog::OnButtonSearch() 
{
    HRESULT hr=S_OK;
    int nFilters = 0;    

	IEnumMoniker *pEnum = NULL;
    IMoniker *pMoniker=0;

    // Clear any previous results
    m_ListFilters.ClearItems();

    // Enumerate filters based on the current dialog box selections.
	hr = EnumerateFilters(&pEnum);
    if (FAILED(hr))
    {
        return;
    }
	
	// Reset the enumerator.
    hr = pEnum->Reset();  // Not strictly necessary but can't hurt.

	// Go through each moniker in the collection.
    while((hr = pEnum->Next(1, &pMoniker, NULL)) == S_OK)
    {
        IPropertyBag *pPropBag = NULL;
        DWORD dwMerit;
        VARIANT varName;
        VARIANT varFilterClsid;

		VariantInit(&varName);
		VariantInit(&varFilterClsid);

		// Initialize variant types 
		varName.vt = VT_BSTR;
        varFilterClsid.vt = VT_BSTR;

        // Get a property bag for this moniker.
        hr = pMoniker->BindToStorage(
			0, 0, IID_IPropertyBag, (void **)&pPropBag);

	    // Read the filter name from the property bag
        if (SUCCEEDED(hr))
		{
		    hr = pPropBag->Read(L"FriendlyName", &varName, 0);
		}

        
        // Read the Merit value from the property bag
		if (SUCCEEDED(hr))
		{
	        hr = GetMerit(pPropBag, &dwMerit);
		}

        // Read filter's CLSID from property bag.  The CLSID is
		// returned as a string (BSTR).

		if (SUCCEEDED(hr))
		{
	        hr = pPropBag->Read(L"CLSID", &varFilterClsid, 0);
		}

         // Add filter name and filename to listbox
         if(SUCCEEDED(hr))
		 {
			 nFilters++;
			 AddFilterToList(varName.bstrVal, varFilterClsid.bstrVal, dwMerit);
		 }

        // Clean up.
        SysFreeString(varFilterClsid.bstrVal);
        SysFreeString(varName.bstrVal);
        SAFE_RELEASE(pPropBag);
        SAFE_RELEASE(pMoniker);
    }   

    // Display number of filters matching query
    WCHAR szNumFilters[48];
    hr = StringCchPrintf(szNumFilters, NUMELMS(szNumFilters), L"Filters Matching Query : %d\0", nFilters);

    SetDlgItemText(IDC_STATIC_NUMFILTERS, szNumFilters);

	if (nFilters == 0)
	{
        m_ListFilters.AddString(L"<No filters matched query>");
	}

    // Clean up enumerator
    SAFE_RELEASE(pEnum);


}
开发者ID:AbdoSalem95,项目名称:WindowsSDK7-Samples,代码行数:91,代码来源:maindialog.cpp

示例12: ListCodecs

void ListCodecs() {
	HRESULT hr;
	ICreateDevEnum *pSysDevEnum = NULL;
	IEnumMoniker *pEnum = NULL;
	IMoniker *pMoniker = NULL;

	pEngfuncs->Con_Printf("Codecs:\n");

	hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, 
		CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, 
		(void**)&pSysDevEnum);
	if (FAILED(hr))
	{
		return;
	}    

	hr = pSysDevEnum->CreateClassEnumerator(
			 CLSID_VideoCompressorCategory, &pEnum, 0);
	if (hr == S_OK)  // S_FALSE means nothing in this category.
	{
		while (S_OK == pEnum->Next(1, &pMoniker, NULL))
		{
			IPropertyBag *pPropBag = NULL;
			pMoniker->BindToStorage(0, 0, IID_IPropertyBag, 
				(void **)&pPropBag);
			VARIANT var;
			VariantInit(&var);
			hr = pPropBag->Read(L"FriendlyName", &var, 0);
			if (SUCCEEDED(hr))
			{
				int ilen=WideCharToMultiByte(
					CP_ACP,
					0,
					var.bstrVal,
					-1,
					NULL,
					0,
					NULL,
					NULL
				);

				LPSTR str = (LPSTR)malloc(ilen);

				if(0 != WideCharToMultiByte(
					CP_ACP,
					0,
					var.bstrVal,
					-1,
					str,
					ilen,
					NULL,
					NULL
				))

				pEngfuncs->Con_Printf("%s\n", str);

				free(str);
			}   
			VariantClear(&var); 
			pPropBag->Release();
			pMoniker->Release();
		}
	}

	pSysDevEnum->Release();
	pEnum->Release();
}
开发者ID:Grimandosa,项目名称:advancedfx,代码行数:67,代码来源:mirv_output.cpp

示例13: CoCreateInstance

HRESULT RecordGraph::BuildGraph(CString recordFileName)
{
	HRESULT hr;
	ICreateDevEnum *pSysAudioCaptureEnum = NULL;
	hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysAudioCaptureEnum);
	if (FAILED(hr))
	{
		return hr;
	}

	IBaseFilter *pAudioCapture = NULL;
	IEnumMoniker *pEnumMoniker = NULL;
	hr = pSysAudioCaptureEnum->CreateClassEnumerator(CLSID_AudioInputDeviceCategory, &pEnumMoniker, 0);
	if (hr == S_OK)
	{
		IMoniker *pMoniker = NULL;
		ULONG fetched;
		BOOL findMicrophone = FALSE;
		while(pEnumMoniker->Next(1, &pMoniker, &fetched) == S_OK && !findMicrophone)
		{
			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);
					if(friendlyName.Find(L"Microphone") >= 0)
					{
						hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void **)&pAudioCapture);
						findMicrophone = TRUE;
					}
					VariantClear(&varName);
					pPropBag->Release();
				}
			}
		}
		pEnumMoniker->Release();
	}
	pSysAudioCaptureEnum->Release();
	if(pAudioCapture == NULL)
	{
		return S_FALSE;
	}
	pBuilder->AddFilter(pAudioCapture, L"Audio Capture");

	IBaseFilter *pWaveDest = NULL;
	hr = CoCreateInstance(CLSID_WavDest, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pWaveDest);
	if(FAILED(hr))
	{
		return hr;
	}
	pBuilder->AddFilter(pWaveDest, L"Wave Dest");

	IBaseFilter *pFileWriter = NULL;
	hr = CoCreateInstance(CLSID_FileWriter, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pFileWriter);
	if(FAILED(hr))
	{
		return hr;
	}
	pBuilder->AddFilter(pFileWriter, L"File Writer");
	IFileSinkFilter *pFileSetter = NULL;
	hr = pFileWriter->QueryInterface(IID_IFileSinkFilter, (void **)&pFileSetter);
	if(FAILED(hr))
	{
		return hr;
	}
	AM_MEDIA_TYPE pmt;
	pmt.majortype = MEDIATYPE_Stream;
	pmt.subtype = MEDIASUBTYPE_WAVE;
	pmt.formattype = FORMAT_WaveFormatEx;
	hr = pFileSetter->SetFileName(recordFileName, &pmt);

	hr = ConnectFilters(pBuilder, pAudioCapture, pWaveDest, MEDIATYPE_NULL);if(FAILED(hr)) return hr;
	hr = ConnectFilters(pBuilder, pWaveDest, pFileWriter, MEDIATYPE_NULL);//if(FAILED(hr)) return hr;
	SaveGraphFile(pBuilder, L"D:\\Record.grf");

	pFileSetter->Release();
	pFileWriter->Release();
	pWaveDest->Release();
	pAudioCapture->Release();
}
开发者ID:LeeBn,项目名称:Navigation,代码行数:86,代码来源:RecordGraph.cpp

示例14: GetDefaultInputDevice

/* Try to intelligently fetch a default video input device */
static HRESULT
GetDefaultInputDevice(IBaseFilter **ppSrcFilter)
{
    HRESULT hr = S_OK;
    IBaseFilter *pSrc = NULL;
    IMoniker *pMoniker = NULL;
    ICreateDevEnum *pDevEnum = NULL;
    IEnumMoniker *pClassEnum = NULL;

    if (!ppSrcFilter) {
        return E_POINTER;
    }

    hr = CoCreateInstance(
        CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
        IID_ICreateDevEnum, (void **)&pDevEnum
    );
    if (FAILED(hr)) return hr;

    hr = pDevEnum->CreateClassEnumerator(
        CLSID_VideoInputDeviceCategory, &pClassEnum, 0
    );
    if (FAILED(hr)) {
        SAFE_RELEASE(pDevEnum);
        return hr;
    }

    if (pClassEnum == NULL) {
        /* No devices available */
        SAFE_RELEASE(pDevEnum);
        return E_FAIL;
    }

    /* Pick the first device from the list.
     * Note that if the Next() call succeeds but there are no monikers,
     * it will return S_FALSE (which is not a failure).
     */
    hr = pClassEnum->Next (1, &pMoniker, NULL);
    if (hr == S_FALSE) {
        SAFE_RELEASE(pDevEnum);
        SAFE_RELEASE(pClassEnum);
        return E_FAIL;
    }

    hr = pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&pSrc);
    if (FAILED(hr)) {
        SAFE_RELEASE(pDevEnum);
        SAFE_RELEASE(pClassEnum);
        SAFE_RELEASE(pMoniker);
        return hr;
    }

    *ppSrcFilter = pSrc;
    (*ppSrcFilter)->AddRef();

    SAFE_RELEASE(pSrc);
    SAFE_RELEASE(pMoniker);
    SAFE_RELEASE(pDevEnum);
    SAFE_RELEASE(pClassEnum);

    return hr;
}
开发者ID:1981khj,项目名称:rainbow,代码行数:63,代码来源:VideoSourceWin.cpp

示例15: QDialog

WelcomeDialog::WelcomeDialog(QWidget* parent) : QDialog(parent) {
    HRESULT hr;
    IMoniker *pMoniker =NULL;
    ULONG cFetched;
    QString lastcam;

	setupUi(this);

	prefs->readEarlyConfig();

    lastcam = prefs->qsVideoDevice;

    CComPtr <ICreateDevEnum> pDevEnum =NULL;

    hr = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
                           IID_ICreateDevEnum, (void **) &pDevEnum);
    if (FAILED(hr))
		qFatal("WelcomeDialog: Couldn't create system enumerator!");

    IEnumMoniker *pClassEnum = NULL;

    hr = pDevEnum->CreateClassEnumerator (CLSID_VideoInputDeviceCategory, &pClassEnum, 0);
    if (FAILED(hr))
    	qFatal("WelcomeDialog: Couldn't create class enumerator");

    if (pClassEnum == NULL)
    	qFatal("WelcomeDialog: No capture device found");

    while (S_OK == (pClassEnum->Next (1, &pMoniker, &cFetched)))
    {
       IPropertyBag *pBag=0;

        hr = pMoniker->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)
            {
				QString name;
				int i = 0;
				while(var.bstrVal[i])
					name.append(QChar(var.bstrVal[i++]));
				comboBoxVideoSource->insertItem(comboBoxVideoSource->count(), name);
				if (name ==lastcam)
					comboBoxVideoSource->setCurrentIndex(comboBoxVideoSource->count()-1);
                SysFreeString(var.bstrVal);
            }
            pBag->Release();
        }
        pMoniker->Release();
    }

    pClassEnum->Release();

    comboBoxVideoSource->setEditable(FALSE);
	lineUsername->setText(prefs->qsUsername);
	lineServer->setText(prefs->qsServer);
	qcbNoReceive->setChecked(prefs->bNoReceive);
	qcbNoAudio->setChecked(prefs->bNoSendAudio);
	qcbLoopback->setChecked(prefs->bLoopback);
	qcbStereo->setChecked(prefs->bStereo);
	qcbNoExclusive->setChecked(prefs->bNoExclusive);
}
开发者ID:thorvald,项目名称:mdvc,代码行数:65,代码来源:WelcomeDialog.cpp


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