본문 바로가기

카테고리 없음

[윈도우즈 API] 시스템 사운드 연주하기

반응형
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, MMSystem;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  PlaySound(pChar('SYSTEMASTERISK'), 0, SND_SYNC);

// 세번째 파라미터로 SND_ASYNC 를 지정하면 thread 로 연주되므로
// background 연주가 됩니다
//
// sound의 다른 종류
// PlaySound(pChar('SYSTEMSTART'), 0, SND_SYNC);
// PlaySound(pChar('SYSTEMHAND'), 0, SND_SYNC);
// PlaySound(pChar('SYSTEMEXIT'), 0, SND_SYNC);
// PlaySound(pChar('SYSTEMQUESTION'), 0, SND_SYNC);
// PlaySound(pChar('SYSTEMEXCLAMATION'), 0, SND_SYNC);
// PlaySound(pChar('SYSTEMEWLCOME'), 0, SND_SYNC);
// PlaySound(pChar('SYSTEMDEFAULT'), 0, SND_SYNC);
end;

end.
반응형