title: CoCreateInstance in the MMDevice API returns error code 0x800401F0
body: <p>As in the title, I am getting an error code that is not in the documentation of <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms686615(v=vs.85).aspx" rel="nofollow noreferrer">CoCreateInstance</a>. The specific error code is 0x800401F0.</p>
  <p>Note: I am new to C++ and programming at this level in general. Trying to learn by building an audio visualization tool.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;Mmdeviceapi.h&gt;
  
  int CALLBACK WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR     lpCmdLine,
    int       nCmdShow
  )
  {
      const CLSID rclsid = __uuidof(MMDeviceEnumerator);
      const IID riid = __uuidof(IMMDeviceEnumerator);
      IMMDeviceEnumerator* pEnumerator;
      IMMDeviceCollection* pEndpoints;
  
      // Create a device enumerator
      HRESULT hr = CoCreateInstance(
          rclsid,
          NULL,
          CLSCTX_ALL,
          riid,
          reinterpret_cast&lt;void **&gt;(&amp;pEnumerator)
      ); 
      if (FAILED(hr)) {
          printf(&quot;%x\n&quot;, hr);
      }
      // Create a collection of endpoints
      // pEnumerator-&gt;EnumAudioEndpoints(
      //  eCapture,
      //  DEVICE_STATE_ACTIVE,
      //  &amp;pEndpoints
      // );
  
      // UINT deviceCount;
      // pEndpoints-&gt;GetCount(&amp;deviceCount);
      // printf(&quot;%u\n&quot;, deviceCount);
  
      return 0;
  }
  </code></pre>
  <p><strong>Compilation</strong>
  <code>gcc audio.cpp -lole32</code></p>
  <p>I am running a 64-bit machine. Not sure if that may be part of the issue.
  Any suggestions?</p>