C#实现基于加减按钮形式控制系统音量及静音的方法
发布时间:2020-12-15 05:56:46 所属栏目:百科 来源:网络整理
导读:本篇章节讲解C#实现基于加减按钮形式控制系统音量及静音的方法。供大家参考研究。具体如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using S
本篇章节讲解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,APPCOMMAND_VOLUME_DOWN * 0x10000); } private void checkBox1_CheckedChanged(object sender,EventArgs e) { //静音 SendMessage(this.Handle,0x200eb0,APPCOMMAND_VOLUME_MUTE * 0x10000); } } } 希望本文所述对大家的C#程序设计有所帮助。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |