C# 調用聲音文件,包括API函數和調用VisualBasic(vs2003)函數

<一>Visual Basic Beep()

1.使用Visual Basic Beep函數;添加引用 Miscorsoft Visual Basic Runtime

 

2.調用 Interaction.Beep();

<二>使用MessageBeep(unit uType):需添加 using System.Runtime.InteropServices;

public const int MB_ICONEXCLAMATION =  48;

  [DllImport("user32.dll")]
  public static extern bool MessageBeep(uint uType);

MessageBeep( MB_ICONEXCLAMATION );

<三>調用Beep(Int freq,int duration)函數

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

Beep(800,300);

<四>調用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("提示時奏幻想空間.WAV",0,SND_ASYNC|SND_FILENAME);

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章