The canonical way of passing a variable number of params to a function/procedure is to use array of const, like does e.g. Format().
lainz,
I don't thing TStringList would work. From the definition of RunCommand it is my understanding that an array of strings is required. I may be wrong.
I suppose you could also use the a CDECL type call and just simulate a multiple list of what ever doing it as done in C ;)Implementing varargs functions is not supported, this can only be used to call external functions.
lainz,
I don't thing TStringList would work. From the definition of RunCommand it is my understanding that an array of strings is required. I may be wrong.
Ok, I see. I'm used to TProcess that uses a list, never used RunCommand. :)
function RunCommand(const exename:TProcessString;const commands:array of TProcessString;out outputstring:string; Options : TProcessOptions = [];SWOptions:TShowWindowOptions=swoNone):boolean;
Var
p : TProcessnamemacro;
i,
exitstatus : integer;
ErrorString : String;
begin
p:=DefaultTProcess.create(nil);
if Options<>[] then
P.Options:=Options - ForbiddenOptions;
P.ShowWindow:=SwOptions;
p.Executable:=exename;
if high(commands)>=0 then
for i:=low(commands) to high(commands) do
p.Parameters.add(commands[i]);
try
result:=p.RunCommandLoop(outputstring,errorstring,exitstatus)=0;
finally
p.free;
end;
if exitstatus<>0 then result:=false;
end;