C # call system Winmm.dll play music wav mp3

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.