Safearrayputelement Delphi

Asked

Viewed 82 times

0

I have a bit of a problem. I have a DLL in C# with some props that are arrays string[] teste; e Gero a TLB. When importing to Delphi 2007 the TLB. The "test" array goes as PSafeArray.

How do I populate this array via Delphi?

I already create the array, determine the size. However, when filling in with the information I want, it does not fill in, it leaves the position in the empty array. Does anyone know how to explain to me what I’m missing?

Follows excerpt from the code, where "dados.PreencheDados" is a C# function to display the dados.teste[x]:

Bounds[0].lLbound := 0;
Bounds[0].cElements := 1;
x := 0;
dados.teste := SafeArrayCreate(varOleStr,1,Bounds);
SafeArrayPutElement(dados.teste,x, 'Testando');
dados.PreencheDados;

I managed to make it work last week, but I erased the thing from the code that worked and now it’s gone blank and I can’t do it anymore. I hope someone helps me.

  • 2

    Are you sure it’s not a problem that in Delphi arrays start at position 1 and C#, at position 0?

  • The arrays in Delphi I determine the starting position. When I put `Bounds[0]. lLbound := 0; I say that the lowest position of the array is 0.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.