首页 - C#.NET

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

发布时间: 2007-04-19 02:45    作者: 未知    来源: 未知    浏览:    评论

C# 调用声音文件,包括API函数和调用VisualBasic函数

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

 

Smile Big Smile Surprise Stick out tongue Wink Sad Tongue Tied Indifferent Crying Embarrassed Cool Angry Angel Devil [8-|] [:#] [:-*] [:^)] [<:o)] [|-)] Yes Beer Left Hug Music Star Time Snail Pizza Automobile Umbrella Computer Storm [mo] [8o|] [^o)] [+o(] [*-)] [8-)] Coffee No Drinks [Z] Right Hug Cake Broken Heart Gift Wilted Flower Movie Dog Idea Sleep Email Travel Paradise
呢称:

加粗 斜体 下划线 链接 图片 代码 邮件地址 引用 列表

最多只能输入100个字符

Tags

SQL 数据库 asp.net C# XML 控件 .NET教程 程序 事件 数据 安全 代码 Server 客户端 验证 数据库专栏 接口 文件 Oracle DataSet 函数 DataGrid 问题 .net return C#语言 JavaScript 服务 IIS 对象 语句 windows 继承 时间 web.config 设计 开发 参数 变量 解决 字符 ADO.net 环境 VB.Net语言 web 异常 工具 服务器 计算 实例 OLEDB Application VB Word WebService insert asp net 安装 记录

精华推荐

更多

精品下载

更多