Onboard Speakersound (Beep) abspielen

// Aufrufbeispiel
// SpeakerBeep.PlayBeep(1000, 1000);

using System.Runtime.InteropServices;

/// <summary->
/// freeware helper class for creating a onboard system speaker beep
/// (W) 2011 by admin of codezentrale.6x.to
/// </summary->
public static class SpeakerBeep
{
    /// <summary->
    /// http://pinvoke.net/default.aspx/kernel32.Beep
    /// </summary->
    [DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    static extern bool Beep(uint dwFreq, uint dwDuration);
    /// <summary->
    /// Plays a beepsound on onboard speaker
    /// </summary->
    /// <param name=&quot;freq&quot;->desired frequency [Hz]</param->
    /// <param name=&quot;duration&quot;->desired duration [ms]</param->
    /// <returns->true, if successfull, otherwise false</returns->
    public static bool PlayBeep(uint freq, uint duration)
    {
        return Beep(freq, duration);
    }
}