[DllImport("kernel32.dll")]
static extern bool Beep(uint dwFreq, uint dwDuration);
Declare Function Beep Lib "kernel32.dll" (dwFreq As Integer, _
dwDuration As Integer) As Boolean
Unlike MessageBeep, this function is synchronous. (It doesn't return control to its caller until the sound finishes.)
Please add some sample code!
The following sample plays the PC speaker in a series of ascending frequencies:
using System;
using System.Runtime.InteropServices;
class BeepSample
{
[DllImport("kernel32.dll")]
static extern bool Beep(uint dwFreq, uint dwDuration);
static void Main()
{
Console.WriteLine("Testing PC speaker...");
for (uint i = 100; i <= 20000; i++)
{
Beep(i, 5);
}
Console.WriteLine("Testing complete.");
}
}
Added by David C. Carachi
System.Console.Beep, coming in v2.0 (Whidbey) of the .NET Framework