Emettre un son 'windows' sur un événement

genebaud Messages postés 23 Date d'inscription samedi 28 juin 2003 Statut Membre Dernière intervention 20 février 2006 - 10 août 2005 à 00:16
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 - 10 août 2005 à 05:06
bonjour
tout est dans le tittre.
je débute en c#. Pouvez vous m'indiquer la marche à suivre?
merci

2 réponses

Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
10 août 2005 à 01:44
Salut, dans le framework .NET 2.0 il y'a une classe SoundPlayer, pour le framework 1.1 il faut utiliser la fonction Win32 PlaySound:


// Déclaration


using System.Runtime.InteropServices;


private enum SND : uint
{
ALIAS = 0x00010000, // Pour les events Windows.
ASYNC = 0x00000001,
}


[ DllImport( "winmm.dll", SetLastError = true ) ]
private static extern bool PlaySound( string sound, IntPtr module, SND flags );


// Appel


protected override void OnClick( EventArgs e )
{
PlaySound( "notify", IntPtr.Zero, SND.ALIAS | SND.ASYNC );
}


>> voir MSDN
0
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
10 août 2005 à 05:06
Petite précision, en NET 2.0 c'est la classe SystemSounds qui est la plus appropriée.
0
Rejoignez-nous