IAudioEndpointVolume没有名为GetMasterVolumeLevelScalar的成员

时间:2016-01-01 23:51:33

标签: c++ c windows gcc

考虑这个程序:

#include <stdio.h>
#include <windows.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
#include <math.h>
int main() {
  IAudioEndpointVolume *wh;
  IMMDevice *ya;
  IMMDeviceEnumerator *xr;
  CoInitialize(0);
  CoCreateInstance(__uuidof(MMDeviceEnumerator), 0, CLSCTX_INPROC_SERVER,
    __uuidof(IMMDeviceEnumerator), (void**)&xr);
  xr->GetDefaultAudioEndpoint(eRender, eConsole, &ya);
  ya->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, 0, (void**)&wh);
  float zu;
  wh->GetMasterVolumeLevelScalar(&zu);
  printf("%d\n", (int) round(100 * zu));
}

我可以将它编译为C ++,没有问题:

x86_64-w64-mingw32-g++ vol.cpp -lole32

但是,如果我尝试将其编译为C:

x86_64-w64-mingw32-gcc vol.c -lole32

我收到错误,例如:

error: ‘IAudioEndpointVolume’ has no member named ‘GetMasterVolumeLevelScalar’

这个程序似乎不是特别“C ++”,所以导致了什么 问题?另外,我可以更改某些内容,使其编译为C吗?

1 个答案:

答案 0 :(得分:0)

这似乎是这样做的:

#include <initguid.h>

的变化:

  1. &CLSID_MMDeviceEnumerator
  2. __uuidof(MMDeviceEnumerator)代替lpVtbl->GetDefaultAudioEndpoint
  3. GetDefaultAudioEndpoint代替'use strict'; import {Component, bootstrap} from 'angular2/angular2'; // Annotation section @Component({ selector: 'my-app', template: '<h1>Hello {{ name }}</h1>' }) // Component controller class MyApp { constructor() { this.name = 'Max'; } }
  4. Source