自己定义个声音文件,然后调用API不就行了吗!
解决方案 »
- delphi 7.0编写服务
- 如何取得ColorDialog返回的值
- **********来京已2月,找了份工作,自己租个一居室,酒足饭饱思淫欲,今晚准备找个XJ带家里玩,明早向大家汇报战果^_^
- 有哪些免费的加密exe文件的软件呢?且加密后的软件的注册码只能在一部机上使用
- 请问高手,在combobox中的如何在显示时加宽下拉窗口,以显示合部内容.
- 数据插入问题
- 人名前的 红色星号 是什么意思 绿色三角 是什么意思 我什么我的只有一个绿色星号
- 实现界面重定义的问题!
- 如何取得DateSet中各field的类型?
- 急救!急救!急救!
- 如何把一个不可见字符和一段字符串同时写入文本文件?
- 如何用stringgrid画表头?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure sound(mhz:integer);
procedure nosound;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure tform1.sound(mhz : integer);
{MHZ 频率}
var
count : word;
oldport,
newport : byte;begin
count := 1193280 div mhz;
asm
mov al,$b6
out $43,al
mov ax,count
out $42,al
mov al,ah
out $42,al
mov al,3
out $61,al
end;
end;procedure tform1.nosound;
{关喇叭}
begin
asm
mov al,0
out $61,al
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
sound(3435);
sleep(300);
nosound;
end;end.
}InterfaceType
TBleepType = (bOK, bInterrupt, bError);Procedure ShutUp; { Added to help counter the effects of DoBleep (Freq, -1).
If you are producing a tone, & you want to stop without doing another Bleep, call this procedure }Procedure DoBleep (Freq : Word; MSecs : Integer); { Duration of -1 means bleep until the next bleep sent, or ShutUp is called }Procedure Bleep (BleepType : TBleepType);ImplementationUses
{$IFDEF WIN32} Windows, {$ELSE} WinProcs, {$ENDIF}
{$IFNDEF CONSOLE} Forms; {$ENDIF} { Michl Ladislav suggested removing the Forms unit from 32-bit Console Apps, saving 130K }
{ -- --- -- --- -- --- -- --- -- --- -- --- -- --- Assembler Bits for Wind 3.x And '95 -- --- -- --- -- --- -- --- -- --- }Procedure AsmShutUp; {$IFDEF WIN32} Pascal; {$ENDIF}
Begin
Asm
In AL, $61 { Stop Bleeping }
And AL, $FC
Out $61, AL
End;
End;Procedure AsmBeep (Freq : Word); {$IFDEF WIN32} Pascal; {$ENDIF}
Label
Skip;
Begin
Asm
Push BX
In AL, $61
Mov BL, AL
And AL, 3
Jne Skip
Mov AL, BL
Or AL, 3
Out $61, AL
Mov AL, $B6
Out $43, AL
Skip: Mov AX, Freq
Out $42, AL
Mov AL, AH
Out $42, AL
Pop BX
End;
End;{ -- --- -- --- -- --- -- --- -- --- -- --- -- --- Low Level Bits for Wind 3.x And '95 -- --- -- --- -- --- -- --- -- --- }Procedure HardBleep (Freq : Word; MSecs : Integer);
Var
{ Changed FirstTickCount from LongInt to DWord to counter P.Satyanarayana's Delphi 4 Warning - see below }
FirstTickCount : {$IFDEF WIN32} DWord {$ELSE} LongInt {$ENDIF};
Begin
{ Michl Ladislav pointed out that having a delay when the bleep freq is out of range is a waste of 'stuff' so I've added
another BEGIN END }
If (Freq>=20) And (Freq<=5000) Then Begin
AsmBeep (Word (1193181 Div LongInt(Freq)));
If MSecs>=0 Then Begin
{ P.Satyanarayana Get's a warning under Delphi 4 here 'Comparing signed and unsigned types - widened both operands'
This should be cleared up by the fact that FirstTickCount is now a DWord under Win32 }
FirstTickCount:=GetTickCount;
{ Michl Ladislav suggested changing the old WHILE DO to a REPEAT UNTIL so as to fit his modifications in easyer }
Repeat
{ Michl Ladislav suggested removing the Forms unit from 32-bit Console Apps, saving 130K }
{$IFNDEF CONSOLE} If MSecs>1000 Then Application.ProcessMessages; {$ENDIF}
Until ((GetTickCount-FirstTickCount)>LongInt(MSecs));
AsmShutUp;
End;
End;
End;{ -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- Procedures for you to use -- --- -- --- -- --- -- --- -- --- -- --- }Procedure Bleep (BleepType : TBleepType);
Begin
Case BleepType of
bOK: Begin
DoBleep (1047,100);
DoBleep (1109,100);
DoBleep (1175,100);
End;
bInterrupt: Begin
DoBleep (2093,100);
DoBleep (1976,100);
DoBleep (1857,100);
End;
bError: DoBleep (40,500);
End;
End;{$IFDEF WIN32} Var SysWinNT : Boolean; {$ENDIF}Procedure DoBleep (Freq : Word; MSecs : Integer);
Begin
{$IFDEF WIN32} If SysWinNT Then Windows.Beep (Freq, MSecs) Else {$ENDIF}
HardBleep (Freq, MSecs);
End;Procedure ShutUp;
Begin
{$IFDEF WIN32} If SysWinNT Then Windows.Beep (1, 0) Else {$ENDIF}
AsmShutUp;
End;{$IFDEF WIN32} Procedure InitSysType;
Var
VersionInfo : TOSVersionInfo;
Begin
VersionInfo.dwOSVersionInfoSize:=SizeOf (VersionInfo);
GetVersionEx (VersionInfo);
SysWinNt:=VersionInfo.dwPlatformID=VER_PLATFORM_WIN32_NT;
End; Initialization
InitSysType;{$ENDIF}End.