简体   繁体   中英

MessageBeep not playing any sound

I'm trying to use the MessageBeep API to play a sound, but no sound plays.

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);
  • Yes have speakers plugged in
  • Yes the volume is turned up
  • Yes i hear other MessageBeeps (UAC, Default, Error, etc)
  • Yes i hear audio from other application ( what i'm listing to right now is irocnical )
  • Windows 10.0.14393 64-bit
  • Interactively connected (ie not through terminal services remote desktop session)
  • the function (which returns a BOOL ) returns true

    在此处输入图片说明

  • Yes there is a "Default" sound set in the Sounds applet of the Control Panel

    在此处输入图片说明

  • The Beep service is started (although the Beep function is not relevant here)
  • Applications are not allowed to take exclusive control of my default (and only) sound device:

    在此处输入图片说明

  • Windows does not attempt to play any sound; you can see no "output levels" in the Volume Mixer:

    在此处输入图片说明

What am I missing?

Sample code to reproduce the problem

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;

Tested on:

  • Windows 10 64-bit
  • Windows 7 64-bit
  • Windows 7 64-bit

  • Delphi 5

    在此处输入图片说明

  • Delphi 7

    在此处输入图片说明

  • Delphi XE6

    在此处输入图片说明

See Also

Bonus Reading

I've solved this problem right now first step: 第一步 click on the task bar on the speaker icon go in options and you must toogle system sound. Screenshoot are taken on windows 7 familly prenium french version but it may be nearly the same in newest versions.

第二步

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM