سؤال

How can I check and change the system volume in Windows using C#, like so:

if(SystemVolume.vol == 0){
    SystemVolume.vol = 100;
}
هل كانت مفيدة؟

المحلول 2

Look into the concept of "audio sessions" in windows. There are some interfaces suggested by the following link, namely ISimpleAudioVolume, IChannelAudioVolume, and IAudioStreamVolume interfaces.

The code examples given are in C++ though, but it should be useful.

نصائح أخرى

For Windows 10 I created a package called AudioControl.

//Returns a float containing the value (ranging from 0 to 1.0f)
var volume = AudioControl.GetMasterVolume();

//Set the volume (use values between 0 and 1.0f)
AudioControl.SetMasterVolume(1.0f); 
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top