call .net assembly from delphi (PSafeArray)

2019-07-16 05:23发布

问题:

I have assembly written on .net Here is function from that assembly:

public class OMG{
    public Result[] test(){
        var tmp = new List<Result>();
        tmp.Add(new Result(){ var1 = 1, var2 = "test" });
        tmp.Add(new Result(){ var1 = 2, var2 = "test1" });
        return tmp.ToArray();
    }
}
public class Result{
    public int var1;
    public string var2;
}

So, i invoke this function from delphi.

var
tmp : PSafeArray;

...
tmp:= omg.test();

So,here i get PSafeArray, how can i actually retrieve data?

回答1:

Have a look at this article, which explains how to get data in and out of a PSafeArray in Delphi.



标签: .net delphi com