Make a beep using internal PC speaker using C#
ctg | 17 Julio, 2008 23:56Some computers doesn't enable sound card or simply, doesn't have it.
If you want make a beep to force to user to pay attention you can also use P/Invoke to call Beep funciton on Kernel32.dll.
It takes two arguments, the first one the frequency, and the second one the duration and returns a bool for success.
Frequency must be from 37 to 32,767.
using System.Runtime.InteropServices;
public class Foo
{
[DllImport("Kernel32.dll")]
public static extern bool Beep(UInt32 frequency, UInt32 duration);
public static void beepTime()
{
Beep(1000, 300);
System.Threading.Thread.Sleep(300);
Beep(2000, 400);
System.Threading.Thread.Sleep(300);
Beep(500, 200);
System.Threading.Thread.Sleep(300);
}
}
Posted in
C# .
Comentario: (0).
Retroenlaces:(0).
Enlace
«Next post |
Previous post»