October 8th, 2003, 06:24 AM
array pointer passed to function in C#
I have a device with an ActiveX control as well as some C++ dll functions only. I would like to develop my application in C# but am finding some syntactical problems with the provided methods of the ActiveX control.
In order to use the data acquired by the device a pre-initialised buffer or array pointer must be passed to a method of the ActiveX upon completion the array should contain the data and also return an indication of how much data was returned, as shown below (from documentation)
object The control
lpBuff Pointer to the buffer or array in which to copy the
The problem I have is in declaring the buffer. This is what I have tried to no avail.
byte data = new byte[object.datasize]; //(datasize provided by object after acquisition - array initiliased)
fixed (byte * Ptr_Data = Data) //obtaining pointer to array
This should do it as far as Im concerned since I am passing it a pointer to the start of the array... but i get an error stating that it cannot convert int* to int when declared like this. It works when I have it declared like below
This way however does not read any results into the provided pointer. What am I missing? It must be a syntax error.
Looking at the tooltip provided for the method it states "CopyTemplate (int)" but why does the doc say "pointer to buffer" - which is it?
Any help appreciated.