我自己定义了一个线程SoundPlay,用来播放声音
可偶尔的会出现'Thread句柄error'定义
SoundPlay:=TSound.Create(true);
SoundPlay.FreeOnTerminate := true;
释放
if SoundPlay<>nil then
SoundPlay.Terminate;
sndPlaySound(nil,0);
执行
procedure TSound.Execute;
begin
sndplaysound(Pchar(strPath+'sound\Cry.wav'),SND_ASYNC+SND_LOOP)
end;
不知道我的问题出在哪里?
可偶尔的会出现'Thread句柄error'定义
SoundPlay:=TSound.Create(true);
SoundPlay.FreeOnTerminate := true;
释放
if SoundPlay<>nil then
SoundPlay.Terminate;
sndPlaySound(nil,0);
执行
procedure TSound.Execute;
begin
sndplaysound(Pchar(strPath+'sound\Cry.wav'),SND_ASYNC+SND_LOOP)
end;
不知道我的问题出在哪里?
如果CREATE(TRUE)这种情况为线程不会立即执行,而必须调用Resume才能执行此线程。 而调用FreeOnTermite := true则表示此线程在Execute之后将自动释放