빌더의 헬프에서 퍼왔씁니다.
-----------------------------------------------------------
Generates a standard beep using the computer speaker.
Unit
Sysutils
Category
miscellaneous routines
extern PACKAGE void __fastcall Beep(void);
Description
Beep calls the Windows API MessageBeep.
컴투맨 님이 쓰신 글 :
: 에러 체크나 알림을 하기 위해서 스피커를 이용하지 않고,
: 컴퓨터 시스템비프음을 사용하고 싶은데 방법을 모르겠습니다.
:
: 아시는 분은 꼭 좀 가르쳐 주세요^^
:
: 아래는 유사한 소스를 구해 해봤는데 에러가 나더군요.
: 함 살펴봐 주세요...
:
: <소스>
: unit Unit1;
:
: interface
:
: uses
: Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
: StdCtrls;
:
: type
: TForm1 = class(TForm)
: Button1: TButton;
: procedure Button1Click(Sender: TObject);
: private
: { Private declarations }
: public
: { Public declarations }
: end;
:
: var
: Form1: TForm1;
:
: implementation
:
: {$R *.DFM}
:
: procedure BeepStart(pitch:SMALLINT);
: asm
: mov bx, pitch
: mov ax, 34DDh
: mov dx, 0012h
: cmp dx, bx
: jnb @stop
: div bx
: mov bx, ax
: in al, 61h
: test al, 3
: jne @j1
: or al, 3
: out 61h, al
: mov al, 0B6h
: out 43h, al
: @j1:
: mov al, bl
: out 42h, al
: mov al, bh
: out 42h, al
: @stop:
: end;
:
: // Sound 중지
: procedure BeepStop;
: asm
: in al,61H
: and al, 0fcH
: out 61H, al
: end;
:
:
: procedure TForm1.Button1Click(Sender: TObject);
: begin
: BeepStart(100); // 주파수 싸이클수(양수값만 허용), 높을수록 저음
: Sleep(100); // (delay) 1초간 지연
: BeepStop;
: end;
:
: end.
|