I am currently using the CopyMemory as shown above, however, the variable which is passed to the function I have now deciphered is to the first variable in the array from the 3rd party program.
In VB, by using CopyMemory (Options(0), narray, 40) it takes 40 bytes from where [narray] starts in memory and copies that 40 bytes to the beginning of the [Options] array, populating the array with the values from the 3rd party program.
I have attempted this in C# and only the first entry of the [Options] array gets populated. I am passing the [narray] variable as "ref" but when I get the IntPtr of the variable it seems to be to the variable in the function not from the 3rd party program. It seems to be passing as "ref" as I can set the value and the 3rd party program knows that it has been changed.
I am using:
public static int UserFunction (ref double narray)
double myarray = new double
GCHandle myGC = GCHandle.Alloc(myarray, GCHandleType.Pinned);
GCHandle inGC = GCHandle.Alloc(narray, GCHandleType.Pinned);
myarrpointer = myGC.AddrOfPinnedObject();
arrpasspointer = inGC.AddrOfPinnedObject();
CopyMemory (myarrpointer, arrpasspointer, 40);