NormSound:THandle; procedure LoadSound(Res:string;var Snd:THandle); var hResInfo:THandle; begin hResInfo:=FindResource(HInstance,pchar(Res),'IconView'); if hResInfo<>0 then Snd:=LoadResource(HInstance,hResInfo); end; LoadSound('MiniSound',MiniSound);procedure TForm1.Play(Sound:THandle); var lpRes:PChar; begin if Sound<>0 then begin lpRes:=LockResource(Sound); PlaySound(lpRes,0,SND_SYNC OR SND_MEMORY); UnlockResource(Sound); end; end;
有回音,像是同时响了两下。
var
hResInfo:THandle;
begin
hResInfo:=FindResource(HInstance,pchar(Res),'IconView');
if hResInfo<>0 then
Snd:=LoadResource(HInstance,hResInfo);
end; LoadSound('MiniSound',MiniSound);procedure TForm1.Play(Sound:THandle);
var
lpRes:PChar;
begin
if Sound<>0 then begin
lpRes:=LockResource(Sound);
PlaySound(lpRes,0,SND_SYNC OR SND_MEMORY);
UnlockResource(Sound);
end;
end;