procedure TMainForm.sbPlayClick(Sender: TObject);
var
B: TBlobStream;
M: TMemoryStream;
begin
B := TBlobStream.Create(tblSoundsWave, bmRead); // create blob stream
Screen.Cursor := crHourGlass; // wait hourglass
try
M := TMemoryStream.Create; // create memory stream
try
M.CopyFrom(B, B.Size); // copy from blob to memory stream
// Attempt to play sound. Raise exception if something goes wrong
Win32Check(PlaySound(M.Memory, 0, SND_SYNC or SND_MEMORY));
finally
M.Free;
end;
finally
Screen.Cursor := crDefault;
B.Free; // clean up
end;
end;
var
B: TBlobStream;
M: TMemoryStream;
begin
B := TBlobStream.Create(tblSoundsWave, bmRead); // create blob stream
Screen.Cursor := crHourGlass; // wait hourglass
try
M := TMemoryStream.Create; // create memory stream
try
M.CopyFrom(B, B.Size); // copy from blob to memory stream
// Attempt to play sound. Raise exception if something goes wrong
Win32Check(PlaySound(M.Memory, 0, SND_SYNC or SND_MEMORY));
finally
M.Free;
end;
finally
Screen.Cursor := crDefault;
B.Free; // clean up
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货