How can i control volume for specific application!!!
I'm about writing code in C++ which i can use to control volume (for example, Google chrome), I added that function to my code, but it control master volume instead of just the application volume:
Code:
setChangeVolume(const double & iVolume)
{
HRESULT hr=NULL;
double newVolume = iVolume;
CoInitialize(NULL);
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;
unsigned int icurrentVolume = 0;
endpointVolume->GetMasterVolumeLevel(¤tVolume);
hr = endpointVolume->GetMasterVolumeLevelScalar(¤tVolume);
hr = endpointVolume->SetMasterVolumeLevelScalar(static_cast<float>(newVolume), NULL);
endpointVolume->Release();
CoUninitialize();
}
Do you have any idea how to that ? even if it possible to use HKEY (regedit) or if i can control volume for specific process ?
Thanks