Click here to Skip to main content
16,020,669 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,


I am using

C#
[DllImport("kernel32.dll")]
public static extern bool Beep(int frequency, int duration);


It uses internal speaker.if i attach external speaker still it uses internal speaker.
I want beep should play from internal speaker when external speaker are not there but should play from external speakers when present.


Thanks
Posted
Comments
Maarten Kools 14-Jan-14 1:36am    
Unhelpful related to your question, but there's also the Console.Beep[^] method (so you won't have to mess with native methods). And on another note, the PC speaker won't beep on 64bit systems apparently. And here's why[^]
Member 4354249 14-Jan-14 2:00am    
even Console.beep isnt helping
TnTinMn 14-Jan-14 19:34pm    
Based on your stated criteria, I suggest the following API method.

[DllImport("user32", CharSet=CharSet.Unicode)]
internal static extern int MessageBeep(int uType);

with uType = 0xFFFFFFFF -- A simple beep. If the sound card is not available, the sound is generated using the speaker.

see: http://msdn.microsoft.com/en-us/library/windows/desktop/ms680356%28v=vs.85%29.aspx
Member 4354249 14-Jan-14 23:10pm    
but what if there are no speakers?
It should generate sound from system

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900