windows - MessageBeep 不播放任何声音

标签 windows winapi

我正在尝试使用 MessageBeep播放声音的 API,但没有播放声音。

MessageBeep(MB_ICONINFORMATION);
MessageBeep(MB_ICONASTERISK);
MessageBeep(MB_ICONEXCLAMATION);
MessageBeep(MB_ICONERROR);
MessageBeep(MB_ICONHAND);
MessageBeep(MB_ICONINFORMATION);
MessageBeep(MB_ICONQUESTION);
MessageBeep(MB_ICONSTOP);
MessageBeep(MB_ICONWARNING);
MessageBeep(MB_OK);
  • 是的,已插入扬声器
  • 是的,音量已调高
  • 是的,我听到了其他 MessageBeep(UAC、默认、错误等)
  • 是的,我听到了来自其他应用程序的音频 (what i'm listing to right now is irocnical)
  • Windows 10.0.14393 64 位
  • 交互式连接(即不通过终端服务远程桌面 session )
  • 函数(返回 BOOL)返回 true

    enter image description here

  • 是的,在控制面板的声音小程序中设置了“默认”声音

    enter image description here

  • 启动Beep服务(虽然Beep功能在这里不相关)
  • 不允许应用程序独占我的默认(也是唯一)声音设备:

    enter image description here

  • Windows 不会尝试播放任何声音;您在音量混合器中看不到“输出电平”:

    enter image description here

我错过了什么?

重现问题的示例代码

procedure TForm4.Button1Click(Sender: TObject);
begin
    MessageBox(0, 'About to play sounds', 'TestApp', MB_OK);

     MessageBeep(MB_ICONINFORMATION);
     MessageBeep(MB_ICONASTERISK);
     MessageBeep(MB_ICONEXCLAMATION);
     MessageBeep(MB_ICONERROR);
     MessageBeep(MB_ICONHAND);
     MessageBeep(MB_ICONINFORMATION);
     MessageBeep(MB_ICONQUESTION);
     MessageBeep(MB_ICONSTOP);
     MessageBeep(MB_ICONWARNING);
     MessageBeep(MB_OK);
     MessageBeep($ffffffff);
    MessageBox(0, 'After playing sounds', 'TestApp', MB_OK);
end;

测试于:

  • Windows 10 64 位
  • Windows 7 64 位
  • Windows 7 64 位

  • 德尔福 5

    enter image description here

  • 德尔福 7

    enter image description here

  • 德尔福XE6

    enter image description here

另见

红利阅读

最佳答案

我现在已经解决了这个问题 第一步:first step单击扬声器图标上的任务栏 进入选项,你必须toogle系统声音。 屏幕截图是在 Windows 7 家庭 Prenium 法语版上拍摄的,但在最新版本中可能几乎相同。

second step

关于windows - MessageBeep 不播放任何声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42125082/

相关文章:

c++ - 从任务栏缩略图关闭按钮打开处理 WM_CLOSE 时不显示 MessageBox

c++ - 如何使用 FillRect() 绘制子窗口?

sapi - Sapi 5.4 和 Microsoft Speech Platform SDK 11 之间的区别

c++ - Windows中的变量类型

c# - 获取文件夹 ID C#

c++ - Youtube 与 WINAPI GetForegroundWindow() 的交互?

c++ - "xxx.exe is not a valid Win32 application"在 VS 刚刚构建之后

windows - 在 gui 中包装 rsync 进度的最佳方法?

c++ - 文件中的数据位置

windows - 如何在 Windows 上卸载 Atom 文本编辑器?