Last active
October 22, 2017 05:31
-
-
Save hisasann/afd734e688893df345e05185864b5345 to your computer and use it in GitHub Desktop.
windows上でボリュームを変更するコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using CoreAudioApi; | |
namespace DeviceManager.Volume | |
{ | |
class VolumeController | |
{ | |
public void SetVolume(int value) | |
{ | |
// via http://moguriblogg.blogspot.jp/2017/01/c25.html | |
//音量を変更 | |
MMDevice device; | |
MMDeviceEnumerator DevEnum = new MMDeviceEnumerator(); | |
device = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia); | |
device.AudioEndpointVolume.MasterVolumeLevelScalar = ((float)value / 100.0f); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment