MessageBeep没有播放任何声音

时间:2017-02-08 22:45:24

标签: 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);
  • 是的,插入了扬声器
  • 是音量已调高
  • 是的,我听到其他MessageBeeps(UAC,默认,错误等)
  • 是的,我听到其他应用程序的音频(what i'm listing to right now is irocnical
  • Windows 10.0.14393 64位
  • 以交互方式连接(即不通过终端服务远程桌面会话)
  • 函数(返回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位

  • Delphi 5

    enter image description here

  • Delphi 7

    enter image description here

  • Delphi XE6

    enter image description here

另见

奖金阅读

1 个答案:

答案 0 :(得分:0)

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

second step

相关问题