1.AccessVBA使用API关闭系统声音和打开系统声音的源码方法
AccessVBA使用API关闭系统声音和打开系统声音的方法
Access VBA 使用API 关闭系统声音和打开系统声音的 方法
即让整个系统静音及取消静音的代码如下
------VBA 实现 源码--------------------
Private Declare Function FindWindow Lib "user" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user" Alias "FindWindowExA" (ByVal hwnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const BM_GETCHECK = &HF0 ' 取得复选框状态
Private Const BM_SETCHECK = &HF1 '设置复选框状态
' Private Const BST_UNCHECKED = & 设置复选框为未选中状态
' Private Const BST_CHECKED = & 设置复选框为选中状态
Private Sub Command1_Click()
Dim hwnd0 As Long ' 用于记录“音量控制”程序的句柄
Shell "sndvol.exe" ' 启动“音量控制”程序
hwnd0 = FindWindow(vbNullString, "主音量")
Dim hwnd1 As Long ' 用于记录“全部静音”复选框句柄
hwnd1 = FindWindowEx(hwnd0, 0&, "Button", "全部静音(&M)") ' 复选框的类名是"Button"
Dim State As Long ' 用于记录复选框状态,如果复选框处于未选中状态,源码库函数源码则返回0,源码android vlc 源码分析选中状态返回1
State = SendMessage(hwnd1,源码云客服系统源码 BM_GETCHECK, ByVal CLng(0), ByVal CLng(0))
SendMessage hwnd1, BM_SETCHECK, 1, 0 '使系统静音
SendMessage hwnd1, BM_SETCHECK, 0, 0 '使系统发音
End Sub