Any call in C# like Beep in VB.Net

  • Thread starter Thread starter Evgeny Zoldin
  • Start date Start date
E

Evgeny Zoldin

Hi All,

Does anybody know is it possible in C# call a Beep for system speaker like
that one in VB but different from
Microsoft.VisualBasic.Interaction.Beep()

Thanks
 
You could add a reference to "Microsoft Visual Basic .NET Runtime", and have
code like:
Microsoft.VisualBasic.Interaction.Beep();
 
YOu can PInvoke PlaySound and fire the beep wave file. However, Interaction
is made for situations like this, and you don't lose anything by using it.
All it does is wrap that API anyway from what I've been told.

HTH,

Bill
 
Evgeny said:
Hi All,

Does anybody know is it possible in C# call a Beep for system speaker like
that one in VB but different from
Microsoft.VisualBasic.Interaction.Beep()

Thanks

Evgeny,

quickest way i can think of is echo control-g (ascii7), ie, if you're
creating a Console App :)

namespace BeepApp {
class BeepManager {
[STAThread]
static void Main(string[] args) {
BeepManager bm = new BeepManager();
bm.Beep();
Console.ReadLine();
}

public void Beep() {
Console.WriteLine((char)7);
}
}
}
 
Hi All,
Does anybody know is it possible in C# call a Beep for system speaker like
that one in VB but different from
Microsoft.VisualBasic.Interaction.Beep()

Thanks

Try using this:

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)
{
Beep(1000,1000);
}
}
 
Back
Top