Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Beep and MessageBeep

Beep and MessageBeep

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cedricvictor
    wrote on last edited by
    #1

    Dear all; I wanna implement a application. 1.play sound from buzzer on motherboard in win xp, win 7, win 8. 2.play wav from sound card in win xp, win 7, win 8. The function 2 is OK, but the function 1 failed. (A)use Beep function i. works on win xp. ii. failed on win 7, the sound just play from the sound card. iii. failed on win 8, the sound just play from the sound card. (B)use MessageBeep function i. Did not test on win xp. ii.failed on win 7, the sound just play from the sound card. iii.Did not test on win 8. Somebody says the Beep.sys was different between win xp and win 7. I don't want to replace the Beep.sys on win 7. How can I implement this application? Thanks for your help. Victor

    J _ 2 Replies Last reply
    0
    • C cedricvictor

      Dear all; I wanna implement a application. 1.play sound from buzzer on motherboard in win xp, win 7, win 8. 2.play wav from sound card in win xp, win 7, win 8. The function 2 is OK, but the function 1 failed. (A)use Beep function i. works on win xp. ii. failed on win 7, the sound just play from the sound card. iii. failed on win 8, the sound just play from the sound card. (B)use MessageBeep function i. Did not test on win xp. ii.failed on win 7, the sound just play from the sound card. iii.Did not test on win 8. Somebody says the Beep.sys was different between win xp and win 7. I don't want to replace the Beep.sys on win 7. How can I implement this application? Thanks for your help. Victor

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      See the Beep function[^] in the MSDN. It describes why the sound is generated by the sound card with Windows 7 and later. Modern PC systems did not have the timer chip to generate the sound for the internal speaker. Without the timer chip, there is no need for an internal speaker. Some system manufacturers has therefore added a buzzer to their systems. But this is not true for all systems. So you should use the MessageBeep() function which decides how to play the sound. Your application may also check for the Windows version and use the Beep() function whith XP. But you can not rely on the existance of an internal speaker or buzzer.

      _ C 2 Replies Last reply
      0
      • J Jochen Arndt

        See the Beep function[^] in the MSDN. It describes why the sound is generated by the sound card with Windows 7 and later. Modern PC systems did not have the timer chip to generate the sound for the internal speaker. Without the timer chip, there is no need for an internal speaker. Some system manufacturers has therefore added a buzzer to their systems. But this is not true for all systems. So you should use the MessageBeep() function which decides how to play the sound. Your application may also check for the Windows version and use the Beep() function whith XP. But you can not rely on the existance of an internal speaker or buzzer.

        _ Offline
        _ Offline
        _Flaviu
        wrote on last edited by
        #3

        But you can not rely on the existance of an internal speaker or buzzer I guess that every PC has something that buzz when he had no RAM inserted in he's RAM slot ... or not ?

        J 1 Reply Last reply
        0
        • _ _Flaviu

          But you can not rely on the existance of an internal speaker or buzzer I guess that every PC has something that buzz when he had no RAM inserted in he's RAM slot ... or not ?

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          You are probably right about the buzzer.

          1 Reply Last reply
          0
          • J Jochen Arndt

            See the Beep function[^] in the MSDN. It describes why the sound is generated by the sound card with Windows 7 and later. Modern PC systems did not have the timer chip to generate the sound for the internal speaker. Without the timer chip, there is no need for an internal speaker. Some system manufacturers has therefore added a buzzer to their systems. But this is not true for all systems. So you should use the MessageBeep() function which decides how to play the sound. Your application may also check for the Windows version and use the Beep() function whith XP. But you can not rely on the existance of an internal speaker or buzzer.

            C Offline
            C Offline
            cedricvictor
            wrote on last edited by
            #5

            Dear Jochen: My computer install two operation system, win xp and win 7 use MessageBeep() 1.XP-Did not test. 2.Win 7- The sound play from sound card, not buzzer. use Beep() 1.XP-The sound from buzzer. 2.Win 7- The sound play from sound card, not buzzer. So I ensure the buzzer exist. Anything else method? Thank for your help, Victor

            J 1 Reply Last reply
            0
            • C cedricvictor

              Dear Jochen: My computer install two operation system, win xp and win 7 use MessageBeep() 1.XP-Did not test. 2.Win 7- The sound play from sound card, not buzzer. use Beep() 1.XP-The sound from buzzer. 2.Win 7- The sound play from sound card, not buzzer. So I ensure the buzzer exist. Anything else method? Thank for your help, Victor

              J Offline
              J Offline
              Jochen Arndt
              wrote on last edited by
              #6

              The simplest solution to use the buzzer/speaker with XP and the soundcard with Vista and later is:

              OSVERSIONINFO osvi;
              osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
              GetVersionEx(&osvi);
              if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId && osvi.dwMajorVersion >= 6)
              ::MessageBeep(-1);
              else
              ::Beep(1000, 1000);

              If you want to use the buzzer with Windows Vista and later, you must replace the beep.sys driver (which is a bad option). There may be alternatives by accessing the buzzer by low level code. But these will probably not work with 64-bit Windows versions. If have found BEEPx at http://www.waldbauer.com/tmp/reference.php[^].

              1 Reply Last reply
              0
              • C cedricvictor

                Dear all; I wanna implement a application. 1.play sound from buzzer on motherboard in win xp, win 7, win 8. 2.play wav from sound card in win xp, win 7, win 8. The function 2 is OK, but the function 1 failed. (A)use Beep function i. works on win xp. ii. failed on win 7, the sound just play from the sound card. iii. failed on win 8, the sound just play from the sound card. (B)use MessageBeep function i. Did not test on win xp. ii.failed on win 7, the sound just play from the sound card. iii.Did not test on win 8. Somebody says the Beep.sys was different between win xp and win 7. I don't want to replace the Beep.sys on win 7. How can I implement this application? Thanks for your help. Victor

                _ Offline
                _ Offline
                _Superman_
                wrote on last edited by
                #7

                IIRC, Beep is synchronous and MessageBeep is asynchronous. MessageBeep is the recommended way to go. To play a real WAV file, you could use the PlaySound[^] function.

                «_Superman_»  _I love work. It gives me something to do between weekends.

                _Microsoft MVP (Visual C++) (October 2009 - September 2013)

                Polymorphism in C

                C 1 Reply Last reply
                0
                • _ _Superman_

                  IIRC, Beep is synchronous and MessageBeep is asynchronous. MessageBeep is the recommended way to go. To play a real WAV file, you could use the PlaySound[^] function.

                  «_Superman_»  _I love work. It gives me something to do between weekends.

                  _Microsoft MVP (Visual C++) (October 2009 - September 2013)

                  Polymorphism in C

                  C Offline
                  C Offline
                  cedricvictor
                  wrote on last edited by
                  #8

                  Dear «_Superman_»: I want to play sound from buzzer on computer, not from sound card. Thank for your help, Victor.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups