Sound in C# ???

  • Thread starter Thread starter Leif Andersson
  • Start date Start date
L

Leif Andersson

Hi All!

A simple question; what is the C# equivalent for Beep() in VB?
And how can I use the system sound from C#?

Thanks in advance!

/Leif Andersson
 
Greets,

You can use the System.Runtime.InteropServices with Platform Invoke to
call the Win32 Beep API function. Use the following DllImport attribute:

[DllImport("kernel32.dll", EntryPoint="Beep")]
public static extern bool Beep(int frequency, int duration);

Regards,

Joe
 
Thanx Joe!

/Leif

Joe said:
Greets,

You can use the System.Runtime.InteropServices with Platform Invoke to
call the Win32 Beep API function. Use the following DllImport attribute:

[DllImport("kernel32.dll", EntryPoint="Beep")]
public static extern bool Beep(int frequency, int duration);

Regards,

Joe

Hi All!

A simple question; what is the C# equivalent for Beep() in VB?
And how can I use the system sound from C#?

Thanks in advance!

/Leif Andersson
 
Leif,

It should be noted that instead of using interop, you can use the static
Beep method on the Interaction class in the Microsoft.VisualBasic namespace,
which is located in Microsoft.VisualBasic.dll. This does the declaration
for you, and acts in exactly the same manner as it would in VB (and is
distributed as part of the framework).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Leif Andersson said:
Thanx Joe!

/Leif

Joe said:
Greets,

You can use the System.Runtime.InteropServices with Platform Invoke to
call the Win32 Beep API function. Use the following DllImport attribute:

[DllImport("kernel32.dll", EntryPoint="Beep")]
public static extern bool Beep(int frequency, int duration);

Regards,

Joe

Hi All!

A simple question; what is the C# equivalent for Beep() in VB?
And how can I use the system sound from C#?

Thanks in advance!

/Leif Andersson
 
This has been addressed several times here.

I have compiled the common answers in my snippets page found at

http://www.publicjoe.f9.co.uk/csharp/snip/snip001.html

Hope this helps

Mike



Nicholas Paldino said:
Leif,

It should be noted that instead of using interop, you can use the static
Beep method on the Interaction class in the Microsoft.VisualBasic namespace,
which is located in Microsoft.VisualBasic.dll. This does the declaration
for you, and acts in exactly the same manner as it would in VB (and is
distributed as part of the framework).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Leif Andersson said:
Thanx Joe!

/Leif
Invoke
to
call the Win32 Beep API function. Use the following DllImport attribute:

[DllImport("kernel32.dll", EntryPoint="Beep")]
public static extern bool Beep(int frequency, int duration);

Regards,

Joe


Hi All!

A simple question; what is the C# equivalent for Beep() in VB?
And how can I use the system sound from C#?

Thanks in advance!

/Leif Andersson
 
Back
Top