unit1.pas
来自「Delphi6编程大师_多媒体」· PAS 代码 · 共 65 行
PAS
65 行
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
procedure PlayResSound(RESName:String;uFlags:Integer);
public
{ Public declarations }
end;
var
Form1: TForm1;
PtrSound : PChar;
hRes : THandle;
implementation
{$R *.DFM}
{$R Sound.res}
procedure TForm1.PlayResSound(RESName:String;uFlags:Integer);
var
hResInfo,hRes:Thandle;
lpGlob:PChar;
begin
hResInfo:=FindResource(HInstance,PChar(RESName),MAKEINTRESOURCE('WAVEFILE'));
if hResInfo = 0 then
begin
messagebox(0,'Could not find this Resource',PChar(RESName),16);
exit;
end;
hRes:=LoadResource(HInstance,hResinfo);
if hRes = 0 then
begin
messagebox(0,'Could not load this Resource',PChar(RESName),16);
exit;
end;
lpGlob:=LockResource(hRes);
if lpGlob=nil then
begin
messagebox(0,'Resource bad.',PChar(RESName),16);
exit;
end;
uFlags:=snd_Memory or uFlags;
SndPlaySound(lpGlob,uFlags);
UnlockResource(hRes);
FreeResource(hRes);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
PlayResSound(ptrSound,snd_async or snd_Memory);
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?