Passing CLR array to native function

Hi, i have a small problem i hope to get some help with.

I am working with the SerialPort class in .NET 2.0. I want to use the SerialPort's write() method as defined below with the following overloaded arguments.

public:
void Write (
array<unsigned char>^ buffer,
int offset,
int count
)

The program on the other end of the serialPort is using C code. The serialPort on the other end uses a serial port read function which takes in a unsigned char array.

ie. void read(unsigned int i)

Does anyone have any ideas how i can pass my data through? (ie from a CLR array to a function that takes native arrays). I am stuck as there are no overloaded write methods in SerialPort class which allow me to pass a native array. I can only think of one solution at the moment, and that is deriving my own class inherited from SerialPort and overload the write method to take in a native array, but i have no idea to write a method which will write data to a serial port.:(

PS. most of my work is already completed in .NET so there is no chance of starting over in unmanaged C++, and the other end cannot be changed to .NET as it is legacy system.
[1225 byte] By [flakmonkey] at [2007-11-20 1:38:42]
# 1 Re: Passing CLR array to native function
Mixed managed and unmanaged code.
Sample.

//----------

/* memory allocate */

name=(char **)calloc(4,sizeof(char *));

for (int i=0; i<4; i++)

name[i]=(char *)calloc(128,sizeof(char));

name[2][0]='-';
name[2][1]='u'
IntPtr p_Tr=Marshal::StringToHGlobalAnsi(FileNa);
name[3]=(char*)(p_Tr.ToPointer() );
//--------
vito_r at 2007-11-9 12:07:27 >