function GetLen(S: string): Integer;
var
Len: Integer;
begin
Result := 1;
Len := Length(S);
while not (S[Result] = #0) and (Result < Len) do Inc(Result);
end;
procedure TWaveOut.CheckError(Res: Integer);
var
S: string;
begin
if Res <> 0 then
begin
SetLength(S, MAXERRORLENGTH);
waveOutGetErrorText(Res, PChar(S), MAXERRORLENGTH);
//waveInGetErrorText(Res, PChar(S), MAXERRORLENGTH);
SetLength(msg, GetLen(msg));
raise EWaveException.Create(msg);
end;
end;