Mute Windows Volume using C#

后端 未结 7 1319
广开言路
广开言路 2020-11-30 05:01

Anyone know how to programmatically mute the Windows XP Volume using C#?

7条回答
  •  旧巷少年郎
    2020-11-30 05:53

    See How to programmatically mute the Windows XP Volume using C#?

    void SetPlayerMute(int playerMixerNo, bool value)
    {
        Mixer mx = new Mixer();
        mx.MixerNo = playerMixerNo;
        DestinationLine dl = mx.GetDestination(Mixer.Playback);
        if (dl != null)
        {
            foreach (MixerControl ctrl in dl.Controls)
            {
                if (ctrl is MixerMuteControl)
                {
                    ((MixerMuteControl)ctrl).Value = (value) ? 1 : 0;
                    break;
                }
            }
        }
    }
    

提交回复
热议问题