Vb.net Volume control
I was wondering if it is possible to change the master volume from a vb.net application? I can't seem to get it to work.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
jingeRank #2,527 · 554 reputationPosted Oct 18, 2009, 6:22 PM EDT
Exactly.
Here's the code:
Public Class Form1 _ Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr End Function Const WM_APPCOMMAND As UInteger = &H319 Const APPCOMMAND_VOLUME_UP As UInteger = &HA Const APPCOMMAND_VOLUME_DOWN As UInteger = &H9 Const APPCOMMAND_VOLUME_MUTE As UInteger = &H8Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'increase volume
SendMessage(Me.Handle, WM_APPCOMMAND, &H30292, APPCOMMAND_VOLUME_UP * &H10000)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'decrease volume
SendMessage(Me.Handle, WM_APPCOMMAND, &H30292, APPCOMMAND_VOLUME_DOWN * &H10000)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'mute & restore
SendMessage(Me.Handle, WM_APPCOMMAND, &H200EB0, APPCOMMAND_VOLUME_MUTE * &H10000)
End Sub
End Class
Let me know if there's any problem.
Eric4 reputationPosted Oct 19, 2009, 1:12 PM EDT
That is perfect!