My question is related to trying to call a function written in C with C #. I looked at the header file that came with the C library to understand the functions as they exist in the C dll. Here is what I see:
C code (for a function called LocGetLocations):
typedef enum {
eLocNoError,
eLocInvalidCriteria,
eLocNoMatch,
eLocNoMoreLocations,
eLocConnectionError,
eLocContextError,
eLocMemoryError
} tLocGetStatus;
typedef void *tLocFindCtx;
typedef void *tLocation;
PREFIX unsigned int POSTFIX LocGetLocations
(
tLocFindCtx pCtx,
tLocation *pLoc,
unsigned int pNumLocations,
tLocGetStatus *pStatus
);
In C #, I have this:
[DllImport(@"VertexNative\Location.dll")]
public static extern uint LocGetLocations(IntPtr findContext, out byte[] locations, uint numberLocations, out int status);
The problem is that I don’t quite know how to handle the pLoc parameter in C #. I pass it as an array of bytes, although I'm not sure if this is correct. The C library documentation says this parameter is a pointer to an array of descriptors.
How can I get an array on the C # side and access its data?
An example I gave in C looks like this:
tLocation lLocation[20];
LocGetLocations(lCtx, lLocation, 20, &lStatus)
Any help would be greatly appreciated!