C#完成基於加減按鈕情勢掌握體系音量及靜音的辦法。本站提示廣大學習愛好者:(C#完成基於加減按鈕情勢掌握體系音量及靜音的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#完成基於加減按鈕情勢掌握體系音量及靜音的辦法正文
本文實例講述了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#法式設計有所贊助。