调用系统组件,mediaplayer的就可以

解决方案 »

  1.   

    System.Diagnostics.Process.Start("www.wav");
      

  2.   

    如果你要用API,可以用mcisendstring。
      

  3.   

    用DirectShow
    或者
    用WMP
      

  4.   

    using System.Runtime.InteropServices; sndPlay.PlaySound(
    "ring.wav", /*文件名自己改*/
    0,
    (int)sndPlay.PlayingFlags.SND_SYNC
    );

    API函数: public class sndPlay 
    {
     
    [DllImport("winmm.dll", EntryPoint="PlaySound")]
    public static extern bool PlaySound(ref Byte snd, IntPtr hmod, uint fdwSound);
      
    [DllImport("winmm.dll", EntryPoint="PlaySound")]
    public static extern int PlaySound(string  lpszName,int hModule,int dwFlags);
     
    public enum PlayingFlags :uint 
    {
    SND_SYNC = 0x00,
    SND_ASYNC = 0x01,
    SND_NODEFAULT = 0x02,
    SND_MEMORY = 0x04,
    SND_ALIAS = 0x010000,
    SND_FILENAME = 0x020000,
    SND_RESOURCE = 0x040004,
    SND_ALIAS_ID = 0x0110000,
    SND_ALIAS_START = 0,
    SND_LOOP = 0x08,
    SND_NOSTOP = 0x010,
    SND_VALID = 0x01F,
    SND_NOWAIT = 0x02000,
    SND_PURGE = 0x40
    }
    }