C # calling Sound functions (playsound,beep,messagebeep, etc.)

Source: Internet
Author: User
Tags bool
Function


< a >visual Basic Beep ()

1. Use Visual Basic beep functions; Add references miscorsoft Visual Basic Runtime

2. Call Interaction.Beep ();

< two > Using MessageBeep (Unit Utype): Need to add using System.Runtime.InteropServices;

public const int mb_iconexclamation = 48;

[DllImport ("user32.dll")]
public static extern bool MessageBeep (UINT utype);

MessageBeep (mb_iconexclamation);

< three > Call beep (Int freq,int duration) function

[DllImport ("kernel32.dll")]
public static extern bool Beep (int freq,int duration);

Beep (800,300);

< four > Call PlaySound (String pszsound,int hmod,int fdwsound)
[DllImport ("Winmm.dll")]
public static extern bool PlaySound (string pszsound,int hmod,int fdwsound);
public const int snd_filename = 0x00020000;
public const int snd_async = 0x0001;

PlaySound ("Play fantasy space when prompted.") WAV ", 0,snd_async| Snd_filename);




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.