class cPlaySound
{
[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 string strFileName;
public cPlaySound(string strTmp)
{
strFileName = strTmp;
}
//循环播放声音
public void PlayScreenSaver()
{
PlaySound(strFileName, IntPtr.Zero, SND_ASYNC | SND_FILENAME |
SND_LOOP);
}
//停止播放
public void StopScreenSaver()
{
PlaySound(null, IntPtr.Zero, SND_ASYNC);
}
}