How to use variant arrays in Delphi

后端 未结 2 1484
失恋的感觉
失恋的感觉 2020-12-16 12:51

I have two Delphi7 programs: a COM automation server (EXE) and the other program which is using the automation server.

I need to pass an array of bytes from one prog

2条回答
  •  無奈伤痛
    2020-12-16 13:37

    For the other side:

    (assuming Value is the Variant parameter and the element type is WideString)

    var
      Source: PWideStringArray;
    
    if VarIsArray(Value) then begin
      Source:= VarArrayLock(Value);
      try
        for i:= 0 to TVarData(Value).VArray^.Bounds[0].ElementCount - 1 do
          DoWhatEverYouWantWith(Source^[i]);
        end;
      finally
        VarArrayUnlock(Value);
      end;
    end;  
    

提交回复
热议问题