winform 调用声音文件

[DllImport("winmm.dll")]
        public static extern bool PlaySound(string pszSound, int hmod, int fdwSound);
        public const int SND_FILENAME = 0x00020000;
        public const int SND_ASYNC = 0x0001;
//声音文件的名称 strName
        public static void GetSound(string strName)
        {
            PlaySound(Application.StartupPath + string.Format("\\{0}.wav", strName), 0, SND_ASYNC | SND_FILENAME);//声音格式wav,文件存放在程序根目录
        }

你可能感兴趣的:(Winform)