我想用该功能更改主音量
MMRESULT waveOutSetVolume(
HWAVEOUT hwo,
DWORD dwVolume
);
hwo
Handle to an open waveform-audio output device. This parameter can also be a device identifier.
如何为主卷创建处理程序?
dwVolume
Specifies a new volume setting. The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
If a device does not support both left and right volume control, the low-order word of dwVolume specifies the volume level, and the high-order word is ignored.
如何将音量(例如 75)传递给函数?
像这样尝试:How to change master volume programmatically?对我不起作用!
最佳答案
在 Vista+ 中,无法通过旧版 waveOutXxx
API 更改主音量。使用 WASAPI 代替:
If a device has a hardware volume control, changes made to the control through the
IAudioEndpointVolume
interface affect the volume level both in shared mode and in exclusive mode. If a device lacks hardware volume and mute controls, changes made to the software volume and mute controls through this interface affect the volume level in shared mode, but not in exclusive mode. In exclusive mode, the application and the audio hardware exchange audio data directly, bypassing the software controls.
关于C++ Winapi waveOutSetVolume(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21075539/