|
@@ -1,47 +1,38 @@
|
|
|
using ControlVolume.Views;
|
|
|
using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.ComponentModel;
|
|
|
-using System.Data;
|
|
|
-using System.Drawing;
|
|
|
-using System.Linq;
|
|
|
-using System.Runtime.InteropServices;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
+using ControlVolume.NativeMethods;
|
|
|
|
|
|
namespace ControlVolume
|
|
|
{
|
|
|
- public partial class Form1 : Form
|
|
|
+ public partial class frmMain : 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()
|
|
|
+ public frmMain()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
}
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- SendMessage(this.Handle, WM_APPCOMMAND, 0x30292, APPCOMMAND_VOLUME_UP * 0x10000);
|
|
|
+ User32.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);
|
|
|
+ User32.SendMessage(this.Handle, WM_APPCOMMAND, 0x30292, APPCOMMAND_VOLUME_DOWN * 0x10000);
|
|
|
}
|
|
|
|
|
|
private void button3_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
//静音
|
|
|
- SendMessage(this.Handle, WM_APPCOMMAND, 0x200eb0, APPCOMMAND_VOLUME_MUTE * 0x10000);
|
|
|
+ User32.SendMessage(this.Handle, WM_APPCOMMAND, 0x200eb0, APPCOMMAND_VOLUME_MUTE * 0x10000);
|
|
|
}
|
|
|
|
|
|
private void button4_Click(object sender, EventArgs e)
|