扬声器怎么发不出声音?是不是程序就这样?如果不是,要怎样才能使扬声器发声?
代码可以这样写:
public class SoundPlay
{
[DllImport("winmm.DLL")]
public static extern long sndPlaySound(string strSound, long dwFlat);
public static int SND_SYNC = 0;
public static int SND_ASYNC = 1;
public static int SND_MEMORY = 4;
public static int SND_LOOP = 8;
public static int SND_NOSTOP = 10;
public SoundPlay()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public long sndPlay(string strSound, long dwFlat)
{
return sndPlaySound(strSound, dwFlat);
}
public long Stop()
{
PlaySound(null);
return 0;
}
public void PlaySound(string FileName)
{
this.sndPlay(FileName, SND_ASYNC);
}
}
soundPlay.PlaySound(Application.StartupPath + @"\OK.WAV");