<< back to Chapleau.info

August 2005 - Posts

Ever had a situation when you have a problem, and you don't know (or you don't want to address) the solution? That was this kind of situation when and encountered a problem because I wanted to serialize a Configuration file, that is currently in development, and I was unable to reload the same Test configuration (and later, the users neither when they will upgrade the software).

Guess what, I've search the web, and found that Roy Osherove's   have already developed the exact behavior!

Thanks Roy, saved me hours...

-f.

There is the code to do it!

[DllImport("winmm.dll")]
private static extern bool PlaySound( string szSound, IntPtr hMod, PlaySoundFlags flags );

[Flags]
public enum PlaySoundFlags: int
{
 SND_SYNC = 0x0000,
 SND_ASYNC = 0x0001,
 SND_NODEFAULT = 0x0002,
 SND_LOOP = 0x0008,
 SND_NOSTOP = 0x0010,
 SND_NOWAIT = 0x00002000,
 SND_FILENAME = 0x00020000,
 SND_RESOURCE = 0x00040004
}

PlaySound( strFileName, IntPtr.Zero, soundFlags);

SND_SYNC //plays the sound after the event for example a button being pushed
SND_ASYNC //play sound as soon as event happens
SND_NODEFAULT //don't play the default sound if the soundsource is not found
SND_LOOP //play the wav over and over
SND_NOSTOP //don't stop any currently playing sound
SND_NOWAIT //don't wait if the sound driver is busy
SND_RESOURCE //indicates you are using a wav from a resource
SND_FILENAME //indicates you are using a wav from a file source