playing system sounds?

  • Thread starter Thread starter ilPostino
  • Start date Start date
I

ilPostino

Does anyone know how to play system sounds? Or to install your own sounds
and then call them from the application?

C
 
Does anyone know how to play system sounds? Or to install your own sounds
and then call them from the application?

C

Try:

// PlaySound
[DllImport("winmm.DLL", EntryPoint="PlaySound", SetLastError=true,
CallingConvention=CallingConvention.StdCall)]
public static extern bool PlaySound(string strSound, IntPtr hModule,
int dwFlags);

public enum SoundFlag : int
{
SND_APPLICATION = 0x80,
SND_ALIAS = 0x10000,
SND_ALIAS_ID = 0x110000,
SND_ASYNC = 0x1,
SND_SYNC = 0x0,
SND_FILENAME = 0x20000,
SND_LOOP = 0x8,
SND_MEMORY = 0x4,
SND_NODEFAULT = 0x2,
SND_NOSTOP = 0x10,
SND_NOWAIT = 0x2000,
SND_PURGE = 0x40,
SND_RESOURCE = 0x40004,
}


PlaySound(@"D:\Sounds\Fanfare.wav", IntPtr.Zero,
SoundFlag.SND_FILENAME);
 
Back
Top