当前位置: 移动技术网 > IT编程>开发语言>c# > C#实现基于加减按钮形式控制系统音量及静音的方法

C#实现基于加减按钮形式控制系统音量及静音的方法

2019年07月18日  | 移动技术网IT编程  | 我要评论
本文实例讲述了c#实现基于加减按钮形式控制系统音量及静音的方法。分享给大家供大家参考。具体如下: using system; using system.col

本文实例讲述了c#实现基于加减按钮形式控制系统音量及静音的方法。分享给大家供大家参考。具体如下:

using system; 
using system.collections.generic; 
using system.componentmodel; 
using system.data; 
using system.drawing; 
using system.text; 
using system.windows.forms; 
using system.runtime.interopservices; 
namespace volumnset 
{ 
  public partial class form1 : form 
  { 
    [dllimport("user32.dll", charset = charset.auto, setlasterror = true)] 
    static extern intptr sendmessage(intptr hwnd, uint msg, uint wparam, uint lparam); 
    const uint wm_appcommand = 0x319; 
    const uint appcommand_volume_up = 0x0a; 
    const uint appcommand_volume_down = 0x09; 
    const uint appcommand_volume_mute = 0x08; 
    public form1() 
    { 
      initializecomponent(); 
    } 
    private void button1_click(object sender, eventargs e) 
    { 
      //加音量 
      sendmessage(this.handle, wm_appcommand, 0x30292, appcommand_volume_up * 0x10000); 
    } 
    private void button2_click(object sender, eventargs e) 
    { 
      //减音量 
      sendmessage(this.handle, wm_appcommand, 0x30292, appcommand_volume_down * 0x10000); 
    } 
    private void checkbox1_checkedchanged(object sender, eventargs e) 
    { 
      //静音 
      sendmessage(this.handle, wm_appcommand, 0x200eb0, appcommand_volume_mute * 0x10000); 
    } 
  } 
}

希望本文所述对大家的c#程序设计有所帮助。

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网