[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 调用声音文件
最新推荐文章于 2021-04-21 14:46:32 发布
本文介绍了一个使用C#播放.wav格式声音文件的方法。通过调用PlaySound函数,并设置相应的参数,可以在程序中实现异步播放指定路径下的声音文件。
347

被折叠的 条评论
为什么被折叠?



