Connecting Tech Pros Worldwide Forums | Help | Site Map

How to pass pointer to pointer to c function from c#

Pravin
Guest
 
Posts: n/a
#1: Nov 15 '05
I am trying to access C function from C#. I have made DLL of C Code. I have
exported function to be caled using DEF file. defination of the function I
want to call is have one of the parameter is "Pointer to Pointer to Short"

I want to Pass 2D Array to this function as pointer to pointer. I can send
Single dimention array to C function and it works fine. For passing single
dimention array example has been given in MSDN. Please find URL below

FOR PASSING ARRAYS(URL):
"ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconarrayssample.htm"
the example which I am using for sending singe dimention array is
"TestArrayOfInts" in above document URL

I want to Pass 2D array the same way

----------------------------------------------------------------------------
----

C Fucntion

----------------------------------------------------------------------------
----

void DblArray(short **arrayPassed)
{

*(arrayPassed[0]) += 100;
*(arrayPassed[0] + 1) += 200;
*(arrayPassed[0] + 2 ) += 300;

*(arrayPassed[1]) += 10;
*(arrayPassed[1] + 1) += 20;
*(arrayPassed[1] + 2 ) += 30;

}

----------------------------------------------------------------------------
----


The code should be able to call above function by passing 2D array as
**arrayPassed. The values of array (in C#)
[0][0],[0][1],[0][2],[1][0],[1][1] and [1][2] will be changed by C function.
E.G. value of (array in C#) [1][1] element will be incremented by 20.

Thanks in advance.




Closed Thread