PublicFrmvoice () {InitializeComponent (); } [DllImport ("user32.dll", EntryPoint ="SendMessageA")] Public Static extern intSendMessage (INTPTR handle,intWmsg,intWParam,intLParam); Private Const intWm_appcommand =0x319; Private Const intAPPCOMMAND_VOLUME_UP =Ten; Private Const intAppcommand_volume_down =9; Private Const intAppcommand_volume_mute =8; Private voidButtonvoiceup_click (Objectsender, EventArgs e) {SendMessage (Handle, Wm_appcommand,0x30292, Appcommand_volume_up *0x10000); } Private voidButtonvoicedown_click (Objectsender, EventArgs e) {SendMessage (Handle, Wm_appcommand,0x30292, Appcommand_volume_down *0x10000); } Private voidButtonmute_click (Objectsender, EventArgs e) {SendMessage (Handle, Wm_appcommand,0x200eb0, Appcommand_volume_mute *0x10000); } protected Override voidWndProc (refMessage m)//Monitoring Windows Messages { Const intWm_appcommand =0x319; Switch(m.msg) {//Case Wm_appcommand:// { //MessageBox.Show (m.tostring ()); // } //Break ; } Base. WndProc (refm);//passing system messages from the parent class's WndProc}
C # Programming Volume control