// constants for use with PlaySound
public const int SND_ALIAS = 0x10000;
//lpszName is a string identifying the name of the system event sound to play.
public const int SND_ALIAS_ID = 0x110000;
//lpszName is a string identifying the name of the predefined sound identifier to play.
public const int SND_APPLICATION = 0x80;
//lpszName is a string identifying the application-specific event association sound to play.
public const int SND_ASYNC = 0x1;
//Play the sound asynchronously -- return immediately after beginning to play the sound and have it play in the background.
public const int SND_FILENAME = 0x20000;
//lpszName is a string identifying the filename of the .wav file to play.
public const int SND_LOOP = 0x8;
//Continue looping the sound until this function is called again ordering the looped playback to stop. SND_ASYNC must also be specified.
public const int SND_MEMORY = 0x4;
//lpszName is a numeric pointer refering to the memory address of the image of the waveform sound loaded into RAM.
public const int SND_NODEFAULT = 0x2;
//If the specified sound cannot be found, terminate the function with failure instead of playing the SystemDefault sound. If this flag is not specified, the SystemDefault sound will play if the specified sound cannot be located and the function will return with success.
public const int SND_NOSTOP = 0x10;
//If a sound is already playing, do not prematurely stop that sound from playing and instead return with failure. If this flag is not specified, the playing sound will be terminated and the sound specified by the function will play instead.
public const int SND_NOWAIT = 0x2000;
//If a sound is already playing, do not wait for the currently playing sound to stop and instead return with failure.
public const int SND_PURGE = 0x40;
//Stop playback of any waveform sound. lpszName must be an empty string.
public const int SND_RESOURCE = 0x4004;
//lpszName is the numeric resource identifier of the sound stored in an application. hModule must be specified as that applications module handle.
public const int SND_SYNC = 0x0;
//Play the sound synchronously -- do not return until the sound has finished playing.
//[DllImport("winmm.dll")] // first usage
//private extern static long PlaySound (string lpszName, long hModule, long dwFlags); // first usage
[DllImport("winmm.dll", EntryPoint="PlaySound")] // found on web - works with SND_LOOP
public static extern int PlaySoundA(string lpszName, int hModule, int dwFlags); // found on web - works with SND_LOOP
private void button1_Click(object sender, System.EventArgs e)
{
//PlaySound("C:\\Windows\\Media\\Tada.wav", 0, SND_ASYNC | SND_ALIAS); // first usage
PlaySoundA("C:\\Windows\\Media\\Tada.wav", 0, SND_ASYNC | SND_ALIAS | SND_LOOP); // PlaySoundA for SND_LOOP ability
System.Threading.Thread.Sleep(5000);
PlaySoundA("C:\\Windows\\Media\\Tada.wav", 0, 0);
}