如何检查主音量是否静音

时间:2013-10-30 09:26:34

标签: vb.net

如何检查Windows 7 OS中的主音量是否静音   我有静音或取消静音的代码   即

Public Const APPCOMMAND_VOLUME_MUTE As Integer = &H80000
Public Const APPCOMMAND_VOLUME_UP As Integer = &HA0000
Public Const APPCOMMAND_VOLUME_DOWN As Integer = &H90000
Public Const WM_APPCOMMAND As Integer = &H319
Declare Function SendMessageW Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
MM.SendMessageW(Me.Handle, MM.WM_APPCOMMAND, Me.Handle, CType(MM.APPCOMMAND_VOLUME_MUTE, IntPtr))

这里我不会只检查主valume的静音条件。

提前

1 个答案:

答案 0 :(得分:1)

您可以通过"核心audio.dll"轻松查看。 API。

here下载coreaudio.dll

在您的项目中引用它和..

使用以下代码:

private function getmute() as boolean
    Dim devenum As New MMDeviceEnumerator
    Dim device As MMDevice = devenum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia)
    If device.AudioEndpointVolume.Mute = True Then
        Return True
    Else
        Return False
    End If
End Function
希望这有效......

(抱歉英语不好)