NO

Author Topic: Can't find include file <mmdeviceapi.h>.  (Read 10129 times)

neo313

  • Guest
Can't find include file <mmdeviceapi.h>.
« on: July 28, 2015, 04:58:45 AM »
main.c(4): fatal error #1035: Can't find include file <mmdeviceapi.h>.

How can I use the MMDevice API?

This is usually done in C++:

  const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
  const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
  hr = CoCreateInstance(
         CLSID_MMDeviceEnumerator, NULL,
         CLSCTX_ALL, IID_IMMDeviceEnumerator,
         (void**)&pEnumerator);

including Mmdeviceapi.h and ole32 library.

How can I use this api in C with Pelles?

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Can't find include file <mmdeviceapi.h>.
« Reply #1 on: July 28, 2015, 05:49:51 AM »
With a quick search, all I found about that API is that it is C# (not C++) and thus very likely not going to work with Pelle's C, unless someone has a wrapper for that...

Ralf

neo313

  • Guest
Re: Can't find include file <mmdeviceapi.h>.
« Reply #2 on: July 28, 2015, 05:58:31 AM »
With a quick search, all I found about that API is that it is C# (not C++) and thus very likely not going to work with Pelle's C, unless someone has a wrapper for that...

Ralf

No. The API is C/C++. It is a part of [Core Audio Interfaces](https://msdn.microsoft.com/en-us/library/windows/desktop/dd370805%28v=vs.85%29.aspx). For example, it plays a part in controlling user sound volume in Windows.
« Last Edit: July 28, 2015, 06:03:04 AM by neo313 »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Can't find include file <mmdeviceapi.h>.
« Reply #3 on: July 28, 2015, 06:16:34 AM »
Basic idea for that
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ole2.h>
//#include <mmdeviceapi.h>
//#include <endpointvolume.h>

#pragma comment(lib, "ole32.lib")

//extern
const CLSID CLSID_MMDeviceEnumerator  = {0xBCDE0395,0xE52F,0x467C,0x8E,0x3D,0xC4,0x57,0x92,0x91,0x69,0x2E}; // BCDE0395-E52F-467C-8E3D-C4579291692E
//extern
const IID IID_IMMDeviceEnumerator = {0xA95664D2,0x9614,0x4F35,0xA7,0x46,0xDE,0x8D,0xB6,0x36,0x17,0xE6}; // A95664D2-9614-4F35-A746-DE8DB63617E6

int main(void)
{
CoInitialize(NULL);

LPVOID device = NULL;
HRESULT ok = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL,
CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator,
&device);
CoUninitialize();

return EXIT_SUCCESS;
}
May the source be with you

neo313

  • Guest
Re: Can't find include file <mmdeviceapi.h>.
« Reply #4 on: July 28, 2015, 06:21:48 AM »
Basic idea for that

Interesting. I see you have plucked out the values of CLSID_MMDeviceEnumerator and IID_IMMDeviceEnumerator out of mmdeviceapi.h.

Including mmdeviceapi.h is necessary to get proper function and struct definitions. Unfortunately trying to compile with that header fails.
« Last Edit: July 28, 2015, 06:53:06 AM by neo313 »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Can't find include file <mmdeviceapi.h>.
« Reply #5 on: July 28, 2015, 07:45:39 AM »
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ole2.h>

#define __RPC__deref_out
#define __in
#define __out
#define __in_opt
#define __deref_out
#include <mmdeviceapi.h>
//#include <endpointvolume.h>

#pragma comment(lib, "ole32.lib")

//extern
const CLSID CLSID_MMDeviceEnumerator  = {0xBCDE0395,0xE52F,0x467C,0x8E,0x3D,0xC4,0x57,0x92,0x91,0x69,0x2E}; // BCDE0395-E52F-467C-8E3D-C4579291692E
//extern
const IID IID_IMMDeviceEnumerator = {0xA95664D2,0x9614,0x4F35,0xA7,0x46,0xDE,0x8D,0xB6,0x36,0x17,0xE6}; // A95664D2-9614-4F35-A746-DE8DB63617E6

int main(void)
{
CoInitialize(NULL);

IMMDeviceEnumerator *pEnumerator = NULL;
HRESULT ok = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL,
CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator,
(void**)&pEnumerator);
if (!ok) {
ok = pEnumerator->lpVtbl->Release(pEnumerator);
}
CoUninitialize();

return EXIT_SUCCESS;
}
« Last Edit: July 28, 2015, 10:01:37 AM by TimoVJL »
May the source be with you

neo313

  • Guest
Re: Can't find include file <mmdeviceapi.h>.
« Reply #6 on: July 28, 2015, 08:42:36 AM »
Awesome.

Can you also make endpointvolume.h work? I tried and I don't think it is possible since there is a mess with some missing defines or something like that.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Can't find include file <mmdeviceapi.h>.
« Reply #7 on: July 28, 2015, 03:14:06 PM »
Get the PellesC extension here, I've added "mmdeviceapi.h" & "winapifamily.h".
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Can't find include file <mmdeviceapi.h>.
« Reply #8 on: July 29, 2015, 02:53:36 PM »
Those MinGW x64 headers works too.
May the source be with you