Hi,
I am working on a C# app that is trying to use functionality provided via a C++ DLL. I am having a bit of a hard time getting the DLLImport definitions to work right at the moment.
Here's the C++ side of the equation:
struct Result
{
FLOAT first;
FLOAT second;
};
struct ResultData
{
UINT uint1;
UINT uint2;
Result result;
Result* pResults;
};
#define DllImport __declspec(dllimport)
extern "C"
{
DllImport HRESULT APIENTRY Process(const PCWSTR FileName, const PCWSTR logfileFileName, const PCWSTR DataFileName, ResultData** ppResults);
DllImport HRESULT APIENTRY Release(ResultData* pResults);
}
On the C# side, here's what I have done so far:
[StructLayout(LayoutKind.Sequential)]
public struct Result
{
public float first;
public float second;
}
[StructLayout(LayoutKind.Sequential)]
public struct ResultData
{
public uint uint1;
public uint uint2;
public Result result;
public Result[] Results;
}
DllImport("MyDLL.dll")]
static extern uint Release(ResultData pResults);
[DllImport("MyDLL.dll")]
static extern uint Process(string FileName, string logfileFileName, string DataFileName, ref ResultData ppResults);
Is this the correct way to do it? The thing I am most concerned about is that pResults member of the ResultData structure. I don't want that copied by value as it will be a large amount of data and I don't want to replicate memory... how can I make sure that doesn't happen?
I appreciate your help.