具有变体数组的格式?

时间:2011-12-22 08:27:22

标签: delphi delphi-xe variant

如何将FormatVariant数组一起使用?我有一个例外,应该单独存储消息和参数,以便可以在顶层完成翻译:

TMyException = class (Exception)
private
  FParams : array of Variant;
public
  constructor Create (const Msg : String);
  constructor CreateFmt (const Msg : String; Args : array of Variant);
end;

现在我怎样才能将Format与存储的值一起使用?

1 个答案:

答案 0 :(得分:2)

Format和类似的const数组实际上是作为TVarRec的开放数组实现的。虽然表面上与变体相似,但TVarRec是一个不同的野兽。我推荐Rudy Velthuis的优秀article解释了复制和操作TVarRec数组所需的一些细节。