merou mmxm
merou mmxm

Reputation: 19

list capture device in list or menu

I could not understand how to use a menu or list to allow user to select its appropiate device. There is something missing. I don't get it. Can you enlight my mind please?

void    fillDevices(HWND list)
{

IPropertyBag *tmpBag=NULL;
    tmpMonk->BindToStorage(0,0,IID_IPropertyBag,(void **)&tmpBag);
    VariantInit(&varName);
    //DevicePath-Description-FriendlyName
    checkIt(tmpBag->Read(L"FriendlyName",&varName,0));

// i need to fill it  with device names and be able to chose from the list 

    VariantClear(&varName);
    tmpBag->Release();

}

Upvotes: 0

Views: 311

Answers (1)

Roman Ryltsov
Roman Ryltsov

Reputation: 69642

Windows SDK AMCap sample does exactly this:

// put all installed video and audio devices in the menus
//
void AddDevicesToMenu()
{
// ...
    while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK)
    {
        IPropertyBag *pBag=0;

        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)
            {
                AppendMenu(hMenuSub, MF_STRING, MENU_VDEVICE0 + uIndex,
                    var.bstrVal);
//...

Relative path in Windows SDK: \Samples\multimedia\directshow\capture\amcap

Upvotes: 1

Related Questions