2

I am using Visual Studio 2010 and have included these headers:

#include <Audioclient.h>
#include <mmdeviceapi.h>

Referencing, among others, these functions:

CoCreateInstance
IMMDeviceEnumerator::GetDefaultAudioEndpoint
IMMDevice::Activate

I've linked winmm.lib, but I'm getting errors like this:

Error   8   error LNK2001: unresolved external symbol _IID_IMMDeviceEnumerator  C:\XXXX\XXXX\XXXX.obj   XXXX

What .lib file do I need to link to pick up these functions? Is there any guidance on how to find the .lib associated with a .h file in VS 2010?

I'm looking at some example code from MSDN, but I can't find which library needs to be linked.

MattD
  • 1,324
  • 4
  • 14
  • 28
  • 2
    From [here](http://social.msdn.microsoft.com/Forums/en-US/windowssdk/thread/a6101477-3e3d-4613-9605-e347ecd16b34/), `__uuidof()` should work. – chris Oct 11 '12 at 16:41

1 Answers1

7

From Chris. I Changed the code from this:

hr = CoCreateInstance(
    CLSID_MMDeviceEnumerator, NULL,
    CLSCTX_ALL, IID_IMMDeviceEnumerator,
    (void**)&pEnumerator);

To this:

hr = CoCreateInstance(
         __uuidof(MMDeviceEnumerator), NULL,
         CLSCTX_INPROC_SERVER,
         __uuidof(IMMDeviceEnumerator),
         (void**)&pEnumerator);

Now it links!

MattD
  • 1,324
  • 4
  • 14
  • 28