using
System;
using
System.Windows.Forms;
using
System.Runtime.InteropServices;
using
System.Threading;
class
SimpleWindow : System.Windows.Forms.Form
{
private Thread oThread =
null;
[DllImport("winmm.dll")]
public static
extern long
PlaySound(String lpszName, long hModule,
long dwFlags);
private string m_strSoundFile = "none.wav";
public void
PlayMySound()
{
if (m_strSoundFile.Length > 0)
{
PlaySound(Application.StartupPath + "\\" + m_strSoundFile,
0, 0);
}
m_strSoundFile = "";
oThread.Abort();
}//
End of PlayMySound(..)
public void
PlaySoundInThread(string wavefile)
{
m_strSoundFile = wavefile;
oThread = new Thread(new
ThreadStart(PlayMySound));
oThread.Start();
}//
End of PlaySoundInThread(..)
// Window constructor
SimpleWindow()
{
PlaySoundInThread( "indianajones.wav" );
}
[STAThread]
// Our program entry point.
static void
Main()
{
System.Windows.Forms.Application.Run(new
SimpleWindow());
}
}//
End of SimpleWindow Class |