title: How to get a list of video capture devices (web cameras) on windows? (C++)
body: <p>So we have a simple C++ win32 console app. All we want is to print list of web cameras and other video capture devices that are avaliable. We want to use windows apis as much as possible - no external libs - after all - all we want is to print out a a list - not to fly onto the moon!) How to do such thing?</p>
  
  <p>My own reserch:
  I found this <a href="http://msdn.microsoft.com/en-us/library/dd940326(VS.85).aspx" rel="noreferrer">official msdn sample</a> but I still do not get how to output device list onto screen=( (sorry - I am new to C++)</p>
  
  <p>... some more reserch...</p>
  
  <p>In one of simpliest ms samples on topic found this</p>
  
  <pre><code>HRESULT OnInitDialog(HWND hwnd, ChooseDeviceParam *pParam)
  {
      HRESULT hr = S_OK;
  
      HWND hList = GetDlgItem(hwnd, IDC_DEVICE_LIST);
  
      // Display a list of the devices.
  
      for (DWORD i = 0; i &lt; pParam-&gt;count; i++)
      {
          WCHAR *szFriendlyName = NULL;
  
          hr = pParam-&gt;ppDevices[i]-&gt;GetAllocatedString(
              MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME,
              &amp;szFriendlyName,
              NULL
              );
  
          if (FAILED(hr))
          {
              break;
          }
  
          int index = ListBox_AddString(hList, szFriendlyName);
  
          ListBox_SetItemData(hList, index, i);
  
          CoTaskMemFree(szFriendlyName);
      }
  </code></pre>
  
  <p>looks like it should do the job but I do not get how to include this into simple command line app so to output data...</p>
  
  <hr>
  
  <p>also from this series:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/4290834/how-to-get-a-list-of-video-capture-devices-web-cameras-on-linux-ubuntu-c">How to get a list of video capture devices on linux?</a> and <a href="https://stackoverflow.com/questions/4483366/how-to-get-a-list-video-capture-devices-names-web-cameras-on-linux-ubuntu">special details on getting cameras NAMES</a> with correct, tested answers</li>
  <li><a href="https://stackoverflow.com/questions/4532263/how-to-get-a-list-of-video-capture-devices-web-cameras-on-mac-os-c">How to get a list of video capture devices on Mac OS?</a> with correct, not yet tested by my answers</li>
  <li><a href="https://stackoverflow.com/questions/4286223/how-to-get-a-list-of-video-capture-devices-web-cameras-on-windows-c">How to get a list of video capture devices on windows?</a> with correct, tested answers</li>
  <li><a href="https://stackoverflow.com/questions/4637594/how-to-get-a-list-video-capture-devices-names-web-cameras-using-qt-crossplatfo">How to get a list video capture devices NAMES using Qt (crossplatform)?</a> </li>
  </ul>