Hola novato_erick.
Según entiendo deseas almacenar el contenido de un archivo .wav en un string y luego reproducirlo desde allí con la función
sndPlaySound. Desconozco si hay manera de hacerlo funcionar de ese modo, pero lo dudo.
De este modo no te ofrecerá ningún problema:
Código Delphi
[-]
procedure sonidoconfirma(Sonido: Integer);
var
fichero: string;
begin
case Sonido of
1: fichero:= 'C:\Windows\Media\chimes.wav';
2: fichero:= 'C:\Windows\Media\chord.wav';
3: fichero:= 'C:\Windows\Media\ding.wav';
else
raise Exception.Create('Elección fuera de rango');
end;
with TMemoryStream.Create do
try
LoadFromFile(fichero);
sndPlaySound(Memory, SND_MEMORY + SND_SYNC)
finally
Free
end
end;
Aunque no veo la nececidad de hacerlo de ese modo, sería mucho más simple:
Código Delphi
[-]
procedure sonidoconfirma(Sonido: Integer);
var
fichero: string;
begin
case Sonido of
1: fichero:= 'C:\Windows\Media\chimes.wav';
2: fichero:= 'C:\Windows\Media\chord.wav';
3: fichero:= 'C:\Windows\Media\ding.wav';
else
raise Exception.Create('Elección fuera de rango');
end;
sndPlaySound(PChar(fichero), SND_NODEFAULT + SND_SYNC);
end;
Saludos.