Click here to Skip to main content
16,006,762 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Capture video Pin
Yevgeny Efter10-Jan-07 16:58
Yevgeny Efter10-Jan-07 16:58 
GeneralRe: Capture video Pin
Mark Salsbery10-Jan-07 19:17
Mark Salsbery10-Jan-07 19:17 
AnswerRe: Capture video Pin
Haroon Sarwar10-Jan-07 19:42
Haroon Sarwar10-Jan-07 19:42 
GeneralRe: Capture video Pin
Yevgeny Efter11-Jan-07 1:59
Yevgeny Efter11-Jan-07 1:59 
QuestionQuestion with Directshow Video Compression Pin
godspeed12310-Jan-07 9:08
godspeed12310-Jan-07 9:08 
AnswerRe: Question with Directshow Video Compression Pin
Mark Salsbery10-Jan-07 10:25
Mark Salsbery10-Jan-07 10:25 
GeneralRe: Question with Directshow Video Compression Pin
godspeed12310-Jan-07 10:38
godspeed12310-Jan-07 10:38 
GeneralRe: Question with Directshow Video Compression Pin
Mark Salsbery10-Jan-07 10:50
Mark Salsbery10-Jan-07 10:50 
Then you'll have to use similar code to enumerate the monikers and look for a name that matches.
You'll need a moniker to use BindToObject() to create an object with it.

Here's some code from one of my apps that was commented out (I now persist monikers so I haven't
used this code in a while). It was for capture device monikers but it should be very similar.
In fact, I probably ripped most (if not all) of it out of SDK sample code. Anyway, it gets a
moniker given a name (using the monikers display name). Maybe you can glean something useful
from it Smile | :)
IMoniker *MyClass::GetDSVideoDeviceMonikerByName(LPCTSTR pszName)
{
	IMoniker *pRetMoniker = 0;
 
	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 an enumerator for the video capture category.
		hr = pDevEnum->CreateClassEnumerator(
			CLSID_VideoInputDeviceCategory,
			&pEnum, 0);
 
		if (pEnum)
		{
			LPMALLOC pIMalloc;
			if (S_OK != ::CoGetMalloc(1, &pIMalloc))
			{
				SAFE_RELEASE(pEnum);
				SAFE_RELEASE(pDevEnum);
				return 0;
			}
 
			TCHAR *pszBuf = new TCHAR[300];
 
			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, maybe the next one will work.
				} 
 
 
				// Find the display name.
				LPOLESTR pszDisplayName;
				if (S_OK == pMoniker->GetDisplayName(0,0,&pszDisplayName))
				{
					WideCharToMultiByte(CP_ACP, 0, pszDisplayName, -1, pszBuf, 300, 0, 0);
					pIMalloc->Free(pszDisplayName);
 
					pPropBag->Release();
 
					if (!_tcscmp(pszName, pszBuf))
					{
						pRetMoniker = pMoniker;
						break;
					}
 
					pMoniker->Release();
 
				}  //if (S_OK == pMoniker->GetDisplayName(0,0,&pszDisplayName))
				else
				{
					pPropBag->Release();
					pMoniker->Release();
					continue;  // Skip this one, maybe the next one will work.
				}
			}  //while (pEnum->Next(1, &pMoniker, NULL) == S_OK)
 
			delete[] pszBuf;
			SAFE_RELEASE(pIMalloc);
			SAFE_RELEASE(pEnum);
 
		}  //if (pEnum)
 
		SAFE_RELEASE(pDevEnum);
	}
 
	return pRetMoniker;
}

An alternative is to keep the list of monikers in a container of some kind so they only have to
be enumerated once.
GeneralRe: Question with Directshow Video Compression Pin
godspeed12310-Jan-07 11:01
godspeed12310-Jan-07 11:01 
GeneralRe: Question with Directshow Video Compression Pin
godspeed12310-Jan-07 11:13
godspeed12310-Jan-07 11:13 
GeneralRe: Question with Directshow Video Compression Pin
Mark Salsbery10-Jan-07 13:58
Mark Salsbery10-Jan-07 13:58 
Questionsubclassing/superclassing a button Pin
Niamorh10-Jan-07 8:13
Niamorh10-Jan-07 8:13 
AnswerRe: subclassing/superclassing a button Pin
Mark Salsbery10-Jan-07 8:36
Mark Salsbery10-Jan-07 8:36 
GeneralRe: subclassing/superclassing a button Pin
Niamorh11-Jan-07 4:20
Niamorh11-Jan-07 4:20 
GeneralRe: subclassing/superclassing a button Pin
Mark Salsbery11-Jan-07 4:37
Mark Salsbery11-Jan-07 4:37 
QuestionOpen File Dialog PocketPC Pin
Like2Byte10-Jan-07 8:08
Like2Byte10-Jan-07 8:08 
QuestionImageList_DrawIndirect Problem! Pin
r3dqu33n10-Jan-07 6:15
r3dqu33n10-Jan-07 6:15 
QuestionRe: ImageList_DrawIndirect Problem! Pin
Mark Salsbery10-Jan-07 7:33
Mark Salsbery10-Jan-07 7:33 
AnswerRe: ImageList_DrawIndirect Problem! Pin
r3dqu33n10-Jan-07 8:36
r3dqu33n10-Jan-07 8:36 
GeneralRe: ImageList_DrawIndirect Problem! Pin
Mark Salsbery10-Jan-07 8:42
Mark Salsbery10-Jan-07 8:42 
QuestionProblem with CMap GetStartPosition() Pin
vipin_nvk10-Jan-07 5:22
vipin_nvk10-Jan-07 5:22 
AnswerRe: Problem with CMap GetStartPosition() Pin
PJ Arends10-Jan-07 5:56
professionalPJ Arends10-Jan-07 5:56 
QuestionRe: Problem with CMap GetStartPosition() Pin
David Crow10-Jan-07 5:59
David Crow10-Jan-07 5:59 
QuestionWhat's the problem of my program? Pin
Ming Luo10-Jan-07 5:15
Ming Luo10-Jan-07 5:15 
AnswerRe: What's the problem of my program? Pin
Roger Stoltz10-Jan-07 5:36
Roger Stoltz10-Jan-07 5:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.