2012-08-22 33 views
0

我無法理解如何使用菜單或列表來允許用戶選擇適當的設備。 有什麼缺失。我不明白。你能介意我的想法嗎?列表或菜單中的列表捕獲設備

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(); 

} 

回答

1

的Windows SDK AMCap sample正是這樣做的:

// 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); 
//... 

在Windows SDK的相對路徑:\樣本\多媒體\ DirectShow的\捕獲\ AMCAP