是否可以使用VB.NET中的轨迹栏控件来控制系统音量?
当用户调整轨迹栏的值时,系统的音量也会改变。
提前致谢!
答案 0 :(得分:-1)
我在@dude提供的链接上找到了答案。感谢。
进口系统 导入System.Windows.Forms Imports System.Runtime.InteropServices
命名空间WindowsFormsApplication1 部分公共类Form1 继承表格 Private Const APPCOMMAND_VOLUME_MUTE As Integer =& H80000 Private Const APPCOMMAND_VOLUME_UP As Integer =& HA0000 Private Const APPCOMMAND_VOLUME_DOWN As Integer =& H90000 Private Const WM_APPCOMMAND As Integer =& H319
<DllImport("user32.dll")> _
Public Shared Function SendMessageW(ByVal hWnd As IntPtr, _
ByVal Msg As Integer, ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As IntPtr
End Function
Private Sub btnMute_Click(ByVal sender As Object, ByVal e As EventArgs)
SendMessageW(Me.Handle, WM_APPCOMMAND, _
Me.Handle, New IntPtr(APPCOMMAND_VOLUME_MUTE))
End Sub
Private Sub btnDecVol_Click(ByVal sender As Object, ByVal e As EventArgs)
SendMessageW(Me.Handle, WM_APPCOMMAND, _
Me.Handle, New IntPtr(APPCOMMAND_VOLUME_DOWN))
End Sub
Private Sub btnIncVol_Click(ByVal sender As Object, ByVal e As EventArgs)
SendMessageW(Me.Handle, WM_APPCOMMAND, _
Me.Handle, New IntPtr(APPCOMMAND_VOLUME_UP))
End Sub
End Class
结束命名空间