Ver Mensaje Individual
  #10  
Antiguo 12-11-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Reputación: 26
seoane Va por buen camino
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;

{ TSound }

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.
Responder Con Cita