📄 unit1.pas
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -