怎样才能发出“嘣”的一声?
这一声就是弹出messageBox 的那个错误音。但是不要出现MessageBox,只发出声音。怎么做到?我想要最简单的方法。

解决方案 »

  1.   


    using System.Runtime.InteropServices;[DllImport("user32.dll")]
    public static extern int MessageBeep(uint n); MessageBeep(0);
      

  2.   

    [DllImport("user32.dll")]
    public static extern int MessageBeep(uint n); MessageBeep(0);
      

  3.   

    Beep只能发出蜂鸣生。楼主说的那个得播放一个声音文件。你得先找到你要用的声音文件.
    System.Media.SoundPlayer snd = new SoundPlayer("YOUR_FILE_PATH");
    snd.Play();
      

  4.   

    给大家听一段美妙的音乐:
    using System.Media;
    using System.Threading;namespace Test
    {
        class MyClass
        {
            const int ti = 200;
            static void Main()
            {
                while(true)
                {
                    SystemSounds.Asterisk.Play();
                    Thread.Sleep(ti);
                    SystemSounds.Beep.Play();
                    Thread.Sleep(ti);
                    SystemSounds.Exclamation.Play();
                    Thread.Sleep(ti);
                    SystemSounds.Hand.Play();
                    Thread.Sleep(ti);
                    SystemSounds.Question.Play();
                    Thread.Sleep(ti);
                }
            }
        }
    }