C#实现基于加减按钮形式控制系统音量及静音的方法
程序员文章站
2023-10-31 14:38:10
本文实例讲述了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#程序设计有所帮助。
上一篇: 水蒸蛋水和蛋的比例,快点掌握起来吧!
下一篇: 支付宝账单标签怎么添加?