Beep 其实是调用的 API 函数: MessageBeep(MB_OK);
MessageBeep 有下面几种用法可以调用几种不同的声音文件:
MessageBeep(MB_OK); MessageBeep(MB_ICONHAND); MessageBeep(MB_ICONQUESTION); MessageBeep(MB_ICONEXCLAMATION); MessageBeep(MB_ICONASTERISK); MessageBeep();
Beep 同时也是一个 API 函数, 它可以指定声音的高度和长度; 因为和 SysUtils.Beep 重名了, 所以应该这样调用:
Windows.Beep(音高, 长度);
譬如: Windows.Beep(440, 2000); 会把一个国际标准音(440HZ)演奏 2 秒钟.
另外第一个参数的取值范围是: $25 - $7FFFF.
下面的程序会演奏<奥运会主题歌>的第一句:
Unit1; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; TForm1 = (TForm) Button1: TButton; Button1Click(Sender: TObject); ; Form1: TForm1; TForm1.Button1Click(Sender: TObject); t = ; Windows.Beep(, t); Windows.Beep(, t); Windows.Beep(, t*); Windows.Beep(, t); Windows.Beep(, t); Windows.Beep(, t*); Windows.Beep(, t); Windows.Beep(, t); Windows.Beep(, t); Windows.Beep(, t); Windows.Beep(, t*); ; .