usingSystem.Runtime.InteropServices;//put WAV Public Partial classFrmmain:form {System play music wav MP3 [DllImport ("Winmm.dll")] Public Static extern BOOLPlaySound (stringPszsound,intHmod,intFdwsound);//play Windows music, Reload PublicFrmmain () {InitializeComponent (); } //enter the system to play music Private voidM_systemplaywav (stringstrplayfile) { Try { if(Strplayfile.trim () = ="") { return; }//to be left empty stringstrpath =AppDomain.CurrentDomain.SetupInformation.ApplicationBase; strpath= strpath +Strplayfile; intSnd_filename =0x00020000; intSnd_async =0x0001; PlaySound (strpath,0, Snd_async | Snd_filename);//Play Music } Catch(Exception ex) {//myclass.clsloghelper.m_createerrorlogtxt ("M_systemplaywav win system to put WAV files", Strplayfile, ex. Message.tostring ()); } } Private voidm_systemstopplaywav () {Try{PlaySound (NULL,0,0x40|0x04|0x02); } Catch(Exception ex) {//myclass.clsloghelper.m_createerrorlogtxt ("M_systemstopplaywav win stop to put WAV files","", ex. Message.tostring ()); } }}
C # call system Winmm.dll play music wav mp3