1

スカイプが設定で行うのと同じように、Windows 7 システムで再生されているオーディオの実際のレベルを取得する必要があります。

スカイプ設定

私はそれについて何も見つけていません。

私がやりたいのは、Windowsの音が小さすぎる場合は最大音量を上げるか、音が大きすぎる場合は音量を下げる単純なツールを書きたいということです。

4

2 に答える 2

0

このリンクを試すことができます:

http://www.dreamincode.net/forums/topic/45693-controlling-sound-volume-in-c%23/

基本的に、この win32 api 関数をインポートする必要があります。

[DllImport("winmm.dll")]
public static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);

次に、次のように使用できます。

waveOutGetVolume(IntPtr.Zero, out CurrVol);

そして、「CurrVol」で音量レベルを取得します

于 2012-06-07T15:52:02.267 に答える
0

クラス NAudio をダウンロードし、C# プロジェクトで DLL を参照します。

次に、次のコードをプロジェクトに追加します。すべてのオーディオ デバイスを列挙し、ボリューム レベルを取得して、ミュートしようとします。

        try
        {
            //Instantiate an Enumerator to find audio devices
            NAudio.CoreAudioApi.MMDeviceEnumerator MMDE = new NAudio.CoreAudioApi.MMDeviceEnumerator();
            //Get all the devices, no matter what condition or status
            NAudio.CoreAudioApi.MMDeviceCollection DevCol = MMDE.EnumerateAudioEndPoints(NAudio.CoreAudioApi.DataFlow.All, NAudio.CoreAudioApi.DeviceState.All);
            //Loop through all devices
            foreach (NAudio.CoreAudioApi.MMDevice dev in DevCol)
            {
                try
                {
                    //Get its audio volume
                    System.Diagnostics.Debug.Print("Volume of " + dev.FriendlyName + " is " + dev.AudioEndpointVolume.MasterVolumeLevel.ToString());

                    //Mute it
                    dev.AudioEndpointVolume.Mute = true;
                    System.Diagnostics.Debug.Print(dev.FriendlyName + " is muted");

                    //Get its audio volume
                    System.Diagnostics.Debug.Print(dev.AudioEndpointVolume.MasterVolumeLevel.ToString());
                }
                catch (Exception ex)
                {
                    //Do something with exception when an audio endpoint could not be muted
                    System.Diagnostics.Debug.Print(dev.FriendlyName + " could not be muted");
                }
            }
        }
        catch (Exception ex)
        {
            //When something happend that prevent us to iterate through the devices
            System.Diagnostics.Debug.Print("Could not enumerate devices due to an excepion: " + ex.Message);
        }
于 2012-09-21T16:38:33.177 に答える