我在Windows上运行Lazarus。我真的想让节目“哔哔”。看来,你可以这样做在帕斯卡使用:Lazarus Pascal蜂鸣声命令
windows.beep(300,500);
但不是在拉撒路!是否有另一个我可以使用的命令?
更新:
sysutils.beep()
这工作,但我真的很想设定的频率和声音
我在Windows上运行Lazarus。我真的想让节目“哔哔”。看来,你可以这样做在帕斯卡使用:Lazarus Pascal蜂鸣声命令
windows.beep(300,500);
但不是在拉撒路!是否有另一个我可以使用的命令?
更新:
sysutils.beep()
这工作,但我真的很想设定的频率和声音
Afaik这是可以工作多年的功能。 (Dev Pascal已超过十岁)。
不同之处在于,Lazarus不会像Delphi那样自动将Windows添加到uses子句中。
的持续时间。如果此功能未在拉撒路声明,你可以声明它像:
function Beep(dwFreq, dwDuration: DWORD): BOOL; stdcall; external 'kernel32.dll';
在Lazarus创建一个新项目并添加一个按钮。将windows单元添加到使用列表中。 在按钮的默认事件把你的代码:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
windows; // added by manually
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
n,
freq,dur : integer;
begin
Randomize;
for n:=1 to 100 do
begin
windows.Beep(random(1000)+n,random(100)+100);
end;
end;
end.
是否有任何简单的变通?我真的很想玩弄我正在运行的课程的频率和持续时间 – pluke
没有必要的解决方法。只需添加窗口到使用条款,它应该工作。 –
啊,我明白你的意思了,所以'使用Windows;'修复它。谢谢! – pluke