I'am developping a Delphi program in order to ripp about 500 classical CD's to Apple Lossless format.
The Idea is to create a map for each CD an put the converted tracks therein with my standard naming for each piece of music and each track.
I got support from Mr Spoon to formulate the commandline which allowed me to rip tracks in the planned way by manually input in the cMD form
However if I put together the command in my program each command is rejected with error code 123. I believe the problem is in the way I formulate the command with single and double quotes. Since that area is note my strength, I would like to get some support to finish my program. I give you the relevant portions of my program:
1. ExecAndWait function:
function TfmMM_PARip.ExecAndWait(sExe, sCommandLine: string): Boolean;
var
dwExitCode: DWORD;
tpiProcess: TProcessInformation;
tsiStartup: TStartupInfo;
begin
showmessage('Opdracht = ' + sExe +lf+
'Parameters = ' + sCommandline);
Result := False;
FillChar(tsiStartup, SizeOf(TStartupInfo), 0);
tsiStartup.cb := SizeOf(TStartupInfo);
if CreateProcess(PChar(sExe), PChar(sCommandLine), nil, nil, False, 0,
nil, nil, tsiStartup, tpiprocess) then
begin
if WAIT_OBJECT_0 = WaitForSingleObject(tpiProcess.hProcess, INFINITE) then
begin
if GetExitCodeProcess(tpiProcess.hProcess, dwExitCode) then
begin
if dwExitCode = 0 then
Result := True
else
SetLastError(dwExitCode + $2000);
end;
end;
dwExitCode := GetLastError;
CloseHandle(tpiProcess.hProcess);
CloseHandle(tpiProcess.hThread);
SetLastError(dwExitCode);
end;
end;
2. preparation code
for i := 1 to DbTrk do
begin
with dmMMDm.taRipDb do
begin
indexfieldnames := 'Drgr_Code;Trck_Numm';
Trck := PadN(inttostr(i),3);
if not findkey([Drgr_Code,Trck]) then
Naam := Trck + ' niet gevonden'
else
Naam := fieldbyname('MzDl_Naam').asstring
end;
Src := 'Track' + Padn(inttostr(i),2) + '.cda';
Tgt := 'A:\ripped\';
Path := '"C:\Program Files\dBpoweramp\Coreconverter.exe"';
Parm := '--infile=' + '"H:\' + Src + '" ' +
'--outfile=' + '"' + Tgt + Naam + '.m4a" ' +
'--convert_to=' + '"m4a FDK (AAC)"';
Ripd := ExecAndWait(pchar(Path),pchar(Parm));
if Ripd then
else begin
showmessage('Error code ' + inttostr(GetLastError));
end;
end;
3. The program does "ripp" all tracks but with errorcode 123, so no real ripp is done
Thanks in advance
Chris Elens
The Idea is to create a map for each CD an put the converted tracks therein with my standard naming for each piece of music and each track.
I got support from Mr Spoon to formulate the commandline which allowed me to rip tracks in the planned way by manually input in the cMD form
However if I put together the command in my program each command is rejected with error code 123. I believe the problem is in the way I formulate the command with single and double quotes. Since that area is note my strength, I would like to get some support to finish my program. I give you the relevant portions of my program:
1. ExecAndWait function:
function TfmMM_PARip.ExecAndWait(sExe, sCommandLine: string): Boolean;
var
dwExitCode: DWORD;
tpiProcess: TProcessInformation;
tsiStartup: TStartupInfo;
begin
showmessage('Opdracht = ' + sExe +lf+
'Parameters = ' + sCommandline);
Result := False;
FillChar(tsiStartup, SizeOf(TStartupInfo), 0);
tsiStartup.cb := SizeOf(TStartupInfo);
if CreateProcess(PChar(sExe), PChar(sCommandLine), nil, nil, False, 0,
nil, nil, tsiStartup, tpiprocess) then
begin
if WAIT_OBJECT_0 = WaitForSingleObject(tpiProcess.hProcess, INFINITE) then
begin
if GetExitCodeProcess(tpiProcess.hProcess, dwExitCode) then
begin
if dwExitCode = 0 then
Result := True
else
SetLastError(dwExitCode + $2000);
end;
end;
dwExitCode := GetLastError;
CloseHandle(tpiProcess.hProcess);
CloseHandle(tpiProcess.hThread);
SetLastError(dwExitCode);
end;
end;
2. preparation code
for i := 1 to DbTrk do
begin
with dmMMDm.taRipDb do
begin
indexfieldnames := 'Drgr_Code;Trck_Numm';
Trck := PadN(inttostr(i),3);
if not findkey([Drgr_Code,Trck]) then
Naam := Trck + ' niet gevonden'
else
Naam := fieldbyname('MzDl_Naam').asstring
end;
Src := 'Track' + Padn(inttostr(i),2) + '.cda';
Tgt := 'A:\ripped\';
Path := '"C:\Program Files\dBpoweramp\Coreconverter.exe"';
Parm := '--infile=' + '"H:\' + Src + '" ' +
'--outfile=' + '"' + Tgt + Naam + '.m4a" ' +
'--convert_to=' + '"m4a FDK (AAC)"';
Ripd := ExecAndWait(pchar(Path),pchar(Parm));
if Ripd then
else begin
showmessage('Error code ' + inttostr(GetLastError));
end;
end;
3. The program does "ripp" all tracks but with errorcode 123, so no real ripp is done
Thanks in advance
Chris Elens
Comment