Using system;
Using system. Collections. Generic;
Using system. IO;
Using system. Media;
Using system. runtime. interopservices;
Using system. text;
Namespace pal_mes.brlibrary
{
Class cplaysound
{
/// <Summary>
/// Invoke window API for playing sound file
/// </Summary>
/// <Param name = "lpszsoundname"> filename with its full path </param>
/// <Param name = "fsound"> flag </param>
/// <Returns> </returns>
[Dllimport ("winmm. dll")]
Protected static extern bool sndplaysound (string lpszsoundname, fusound fsound );
/// <Summary>
/// Enum sound Properties
/// </Summary>
Protected Enum fusound
{
Snd_sync = 0,
Snd_async = 1,
Snd_nodefault = 2,
Snd_memory = 4,
Snd_loop = 8
};
/// <Summary>
/// Invoke system API function to play sound file
/// </Summary>
/// <Param name = "strfilewithfullpath"> filename and its absolute path </param>
Public void playsound (string strfilewithfullpath)
{
Try
{
Bool brtn = sndplaysound (strfilewithfullpath, fusound. snd_nodefault );
}
Catch
{
}
}
}
}
Client application: cplaysound sound = new cplaysound ();
Sound. playsound (application. startuppath + @ "\ oo.wav ");