Is it possible to have a vb.net program sound the PC's internal speaker? you know the one that produces C's \a
BELL
I have tried beep()
, but this only produces the error sound on the sound card.
I have also tried
<Runtime.InteropServices.DllImport("KERNEL32.DLL", EntryPoint:="Beep", SetLastError:=True, _
CharSet:=Runtime.InteropServices.CharSet.Unicode, ExactSpelling:=True, _
CallingConvention:=Runtime.InteropServices.CallingConvention.StdCall)> _
Public Shared Function _
aBeep(ByVal dwFreq As Integer, ByVal dwDuration As Integer) _
As Boolean
End Function
With no joy apparently its only good on Vista and above. Any suggestions?
Using the My
namespace in VB.NET, you can get access to audio by going through My.Computer.Audio
. This has a Play
method with a number of overloads that allow you to pass in a .wav sound by file location or as a Byte array or Stream, but it also has a PlaySystemSound
method which takes an enum, one of which is Beep
. So the full line to play this sound is:
My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
No guarantees but as it's part of the .Net framework I think this should work on XP and Vista...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With