Not quite. You have implemented DoProcess() incorrectly, causing undefined behavior. The code compiles, but it will not behave correctly at runtime for certain types. For instance, try passing a single Char into it and your code will crash.
That approach is wrong. You cannot treat all of those types the same way, as they are stored in different ways in the array. vtChar and ctWideChar are stored as individual values in the array itself (like integers are), whereas vtString is a pointer to a ShortString variable, whereas vtAnsiString and vtUnicodeString are copies of the data block pointer from inside of an AnsiString/UnicodeString instance, etc.
You need to handle the various types individually and correctly, eg:
procedure DoProcess(const Args: array of const);
var
i: Integer;
begin
for i := Low(Args) to High(Args) do
begin
case Args[i].VType of
vtString:
Writeln(Args[i].VString^);
vtChar:
Writeln(Args[i].VChar);
vtPChar:
Writeln(Args[i].VPChar);
vtWideChar:
Writeln(Args[i].VWideChar);
vtPWideChar:
Writeln(Args[i].VPWideChar);
vtAnsiString:
Writeln(AnsiString(Args[i].VAnsiString));
vtWideString:
Writeln(WideString(Args[i].VWideString));
vtUnicodeString:
Writeln(UnicodeString(Args[i].VUnicodeString));
vtInteger:
Writeln(Args[i].VInteger);
vtInt64:
Writeln(Int64(Args[i].VInt64));
else
Writeln('Type handling not implemented yet ' + IntToStr(Args[i].VType));
end;
end;
end;
Also, see the MakeStr() example in this earlier post: