Here's a hard way to do it (involves directx 9 sdk)
http://www.codeproject.com/csharp/MessageBeep.asp
And a few other good ways are listed in a message at:
http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=8811
From the 2nd URL, I think my own favorite would be this one (but then
again, i have no particularly bad feelings towards vb).
...you could call VB Runtime Beep like this.
Add referece to Microsoft Visual Basic.NET Runtime
//And then you just use this in your code:
Microsoft.VisualBasic.Interaction.Beep();
-mike
" #Hai" <LH...@SoftHome.net> wrote in message
news:OZWoPzHO...@TK2MSFTNGP10.phx.gbl...
using System;
using System.Runtime.InteropServices;
class MainClass
{
[DllImport("kernel32.dll")]
public static extern bool Beep(int freq,int duration);
public static void Main(string[] args)
{
Console.WriteLine("un beep");
Beep(1000,1000);
Console.WriteLine("un beep più alto e più corto");
Beep(2000,500);
}
}
-Alessandro-
" #Hai" <LH...@SoftHome.net> ha scritto nel messaggio
news:OZWoPzHO...@TK2MSFTNGP10.phx.gbl...
" #Hai" <LH...@SoftHome.net> schrieb:
> I want to send out a small piece of sound (ex: a series of 5 beep)
> to the speaker (by C#).
> How to do that ?
Method 1:
\\\
Console.WriteLine( "\a" ); // Beep
///
Method 2:
\\\
[DllImport("kernel32.dll")]
private static extern bool Beep(int frequency, int duration);
///
Method 3:
\\\
Microsoft.VisualBasic.Interaction.Beep()
///
Method 4:
http://www.palmbytes.de/content/dotnetmisc/klassen.htm
-> class "SystemSound"
Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet