views:

268

answers:

5

Hi, When I tried Console.Beep() on Win Vista (64bit), it just does not work. The speaker itself is OK, when the PC starts, it beeps. Any advice? Thanks!

+2  A: 

Hi there,

the Beep method is not supported on Vista/XP x64. I suppose you do have 64-bit OS?

Jamie
Gosh, how it comes? Yes, 64 Vista:( Any workaround?
Petr
http://msdn.microsoft.com/en-us/library/4fe3hdb1.aspx is a reference to that
Scott Chamberlain
I can confirm that it does work on 64 bit windows 7 (it will use the desktop speakers not the internal pc speaker.)
Scott Chamberlain
Scott, so if you call Comsole.Beep your sound card plays it?
Petr
@Petr: If you prefix a previous commenters name with an `@` they'll get notified that you left them a comment, otherwise @scott might not see it. (missed that Scott had already posted the link I had added to this comment so edited that out)
ho1
A: 

How did you conclude/determine that Vista was the cause of the problem? That is relevant information in this question.

Proclyon
The first thing is to check MSDN in such a situation.
Jamie
This type of questions is probably better suited as a comment underneath the original question. Answers are, somewhat at least, supposed to be answers ;)
Abel
right right , sorry about that, still need to get used to the forum setup. Thank you for the advice!
Proclyon
+9  A: 

Is it 64 bit Vista?

Console.Beep calls the API function Beep which isn't supported on 64bit Vista.

Quote: Windows Vista x64 and Windows XP 64-Bit Edition: This function is not supported.

You might be able to use MessageBeep instead if it's ok with the beep coming through the speakers instead of straight from the motherboard. See here for how to call this from C#.

ho1
Apparently, they had to be told at first, before it become documented, see: https://connect.microsoft.com/VisualStudio/feedback/details/356978/console-beep-doesnt-work-under-vista-64-bit?wa=wsignin1.0
Abel
+1  A: 

As others have suggested, the Console.Beep() does not work on 64 bit windows as the documentation states. Instead, you can use the following statement that issues a beep (but not through the Beep API):

// beep
System.Media.SystemSounds.Beep.Play();

Workaround originally found here at MSDN Connect.

Abel
This does not work. In the SystemSounds there is a Beep but is it not method. SoundsSystems namespace is uknown to my VS 2010
Petr
@Petr: `Beep` is not a method, it is a property of type `SystemSound` (without `s`). It has one method, `Play()`. I fixed the typo though. It works now.
Abel
Thanks. However it just plays the sound associated, no way how to change frequency etc. :(
Petr
@Petr: true. To do that, you can use normal Media methods to create your own sound, but that's a bit more work. As long as the underlying API doesn't work, you're quite stuck here, I'm afraid.
Abel
+2  A: 

As everyone else has posted pc speaker Beep is not supported in 64x of windows vista or XP and not at all in windows 7. Here is a blog posting from Microsoft explaining why

http://blogs.msdn.com/b/larryosterman/archive/2010/01/04/what-s-up-with-the-beep-driver-in-windows-7.aspx

Scott Chamberlain