waveout怎么用?大虾可否给个范例?
我现在的线程比较简单,或者能否请您帮忙改一改?
Unit PlaySounds;
Interface
Uses
Windows, Messages, SysUtils, Classes, Controls,
MMSystem;
Type
TPlaySoundThread = Class(TThread)
Private
Procedure NoticeIt;
Published
Procedure Execute;
Override;
Public
FFilename: String;
FHandle: hWnd;
FMsg: Cardinal;
Constructor Create(Filename:String;Handle:hWnd;Msg:Cardinal);
end;
Implementation
Constructor TPlaySoundThread.Create(Filename:String;Handle:hWnd;Msg:Cardinal);
begin
FFilename:=Filename;
FHandle:=Handle;
FMsg:=Msg;
FreeOnTerminate:=True;
Inherited Create(False);
end;
Procedure TPlaySoundThread.Execute;
Var
p,q
Char;
z:TFilestream;
i,j,k,l,m:integer;
begin
z:=TFileStream.Create(FFilename,fmOpenRead);
i:=z.Size;
p:=AllocMem(i);
q:=p;
j:=i mod 8192;
k:=i div 8192;
for l:=1 to kdo
begin
if l=k then
m:=j else
m:=8192;
z.ReadBuffer(p^,m);
p:=p+m;
end;
z.Free;
sndPlaySound(q,SND_SYNC Or snd_Memory Or Snd_NOSTOP);
//PlaySound(q,0,SND_SYNC Or snd_Memory Or SND_PURGE);
freemem(q,i);
Synchronize(NoticeIt);
end;
Procedure TPlaySoundThread.NoticeIt;
begin
SendMessage(FHandle,FMsg,0,0);
end;
end.