用Api函数播放wav文件

发表于:2007-06-30来源:作者:点击数: 标签:
这个是一段例程,希望能对你有帮助 [DllImport(Winmm)] public static extern bool PlaySound(string pszSound, IntPtr hmod, UInt32 fdwSound); private const Int32 SND_ASYNC = 1; private const Int32 SND_LOOP = 8; private const Int32 SND_FILENAME =
这个是一段例程,希望能对你有帮助

[DllImport("Winmm")]
public static extern bool PlaySound(string pszSound, IntPtr hmod, UInt32
fdwSound);

private const Int32 SND_ASYNC = 1;
private const Int32 SND_LOOP = 8;
private const Int32 SND_FILENAME = 131072;

private void PlayScreenSaver()
{
PlaySound ("BackGround.WAV", IntPtr.Zero, SND_ASYNC | SND_FILENAME |
SND_LOOP);
……
}

private void StopScreenSaver()
{
PlaySound (null, IntPtr.Zero, SND_ASYNC);
……
}


更详细的信息可以到这里看看

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mmfunc_9uxw.asp

原文转自:http://www.ltesting.net