Answer the question
In order to leave comments, you need to log in
How to properly adjust the volume level?
I managed to use it only through winmm.dll, but in windows 10 the sound is regulated only by the application, and I need to adjust the overall volume level.
[DllImport("winmm.dll")]
public static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
...
waveOutSetVolume(IntPtr.Zero, NewVolumeAllChannels);
Answer the question
In order to leave comments, you need to log in
Thanks for the summon.
In Vista and above, the architecture of the audio subsystem has been redesigned, so WASAPI is considered the modern API , and WINMM is considered obsolete.
You can parse the following example: blogs.msdn.com/b/larryosterman/archive/2007/03/06/...
Required headers:
#include <windows.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
IMMDeviceEnumerator *deviceEnumerator = NULL;
hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_INPROC_SERVER, __uuidof(IMMDeviceEnumerator), (LPVOID *)&deviceEnumerator);
IMMDevice *defaultDevice = NULL;
hr = deviceEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &defaultDevice);
deviceEnumerator->Release();
deviceEnumerator = NULL;
IAudioEndpointVolume *endpointVolume = NULL;
hr = defaultDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL, (LPVOID *)&endpointVolume);
defaultDevice->Release();
defaultDevice = NULL;
float currentVolume = 0;
endpointVolume->GetMasterVolumeLevel(¤tVolume);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question