title: MFCreateDeviceSource returns error 0x80070002 for webcam
body: <p><br>
  I'm currently trying to implement webcam video capture into a project.<br>
  First I was trying Direct Show, which worked on one computer but not on another.<br>
  So now I'm trying Media Foundation.<br>
  I mostly followed the examples provided by Microsoft.<br>
  <br>
  Upon calling MFCreateDeviceSource() I receive the error code 0x80070002 (-2147024894).<br>
  This error code is not really documented in this context.<br>
  I get this result for three separate webcams of two different types of webcam, all of which work with other programs using Direct Show (eg VLC).<br>
  Thank you for any hint.</p>
  
  <p>Operating system: Windows7<br>
  SDK: Windows SDK v7.1<br>
  IDE: Visual Studio 2008<br></p>
  
  <p>Code: </p>
  
  <pre><code>// MFStartup(MF_VERSION, MFSTARTUP_NOSOCKET) -- is called successfully in a previous function)
  
  IMFMediaSource*  media_source = 0;
  IMFSourceReader* source_reader = 0;
  IMFAttributes* pAttributes = 0;
  hr = MFCreateAttributes(&amp;pAttributes, 2);
  if (FAILED(hr)) {
      return false;
  }
  // Set the device type to video.
  hr = pAttributes-&gt;SetGUID(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID);
  if (FAILED(hr)) {
      return false;
  }
  // Set the symbolic link.
  hr = pAttributes-&gt;SetString(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK,(LPCWSTR)&amp;device_name);
  if (FAILED(hr)) {
      return false;
  }
  // Create device source interface
  hr = MFCreateDeviceSource(pAttributes, &amp;media_source);
  if (FAILED(hr)) {
      // HERE I RECEIVE 0x80070002
      return false;
  }
  // Create source reader
  IMFAttributes* attr;
  MFCreateAttributes(&amp;attr,1);
  attr-&gt;SetUINT32(MF_SOURCE_READER_ENABLE_VIDEO_PROCESSING,1);
  hr = MFCreateSourceReaderFromMediaSource(media_source,attr,&amp;source_reader);
  if(FAILED(hr)) {
      return false;
  }
  </code></pre>