C#调用声音函数(PlaySound,Beep,MessageBeep等)

王朝c#·作者佚名  2007-01-10
窄屏简体版  字體: |||超大  

<一>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);

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航