Passing a 2D array from vb.net to a C++ function?

  • Thread starter Thread starter AU Gridlock
  • Start date Start date
A

AU Gridlock

Guest
hi, i'm making a call in .net and it is working fine with numbers
Currently I am trying to run it with array2D, I have tried in many ways but it still doesn't work


in C++ project

extern "C"
{
__declspec(dllexport) int __stdcall math_addC(int* &arr) {
double k = 0;
k = *(arr+1); //failed

//Can't Loop arr

return k;
}
}

Call in vb.net

<DllImport("D:\....\Addnumber.dll")>
public Function math_addC(obj as Object,a as Integer,b as Integer) as Integer
end Function

Public Function sumC() As double
dim obj(,) as Object=.... 'Get 2D array
dim k as double
k=math_addC(obj,UBound(obj,1),UBound(obj,2))
return k
End Function

Although I tried with paramter: int ** arr, but the call was still not made.

Its correct value is 15, but the return value is 8004,...

I don't know where wrong. Please help!

Many thanks!

Continue reading...
 
Back
Top