
Exactamente ¿que error te da?
Por otra parte a mi me quedaría una unit mas o menos así:
Código Delphi
[-]
unit Unit2;
interface
uses Windows, Classes;
type
TSound = class(TThread)
private
FList: TStringList;
FMutex: THandle;
protected
procedure Execute; override;
public
constructor Create;
destructor Destroy; override;
procedure Add(Path: String);
end;
implementation
uses mmsystem;
procedure TSound.Add(Path: String);
begin
WaitForSingleObject(FMutex, INFINITE);
try
FList.Add(Path);
finally
ReleaseMutex(FMutex);
end;
end;
constructor TSound.Create;
begin
FList:= TStringList.Create;
FMutex:= CreateMutex(nil,FALSE,nil);
FreeOnTerminate:= TRUE;
inherited Create(FALSE);
end;
destructor TSound.Destroy;
begin
FList.Free;
CloseHandle(FMutex);
inherited;
end;
procedure TSound.Execute;
var
Path: String;
begin
inherited;
while not Terminated do
begin
WaitForSingleObject(FMutex, INFINITE);
try
if FList.Count > 0 then
begin
Path:= FList[0];
FList.Delete(0);
end else
Path:= '';
finally
ReleaseMutex(FMutex);
end;
if Path <> '' then
PlaySound(PChar(Path),0,SND_FILENAME or SND_SYNC)
else
Sleep(10);
end;
end;
end.
Me compila y no me da error alguno.