Hello,
I'm new in c#-c++ marshaling and wrappers. I need to use a c++ dll where there are the next header and struct:
extern "C" __declspec(dllexport) int GiveMeData(LPCTSTR sID, CustomerData* pData)
typedef struct CustomerData
{
LPTSTR customerName
LONG customerItems;
}
In C#, is correct the next wrapper?
[DllImport("Customers.dll")]
public static extern int GiveMeData(string sID, ref CustomerData pData);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct CustomerData
{
public string customerName;
public int customerItems;
}
If isn't correct, how is the best way for do it avoiding possibles heap corruptions, etc?
Thank you!!!!
I'm new in c#-c++ marshaling and wrappers. I need to use a c++ dll where there are the next header and struct:
extern "C" __declspec(dllexport) int GiveMeData(LPCTSTR sID, CustomerData* pData)
typedef struct CustomerData
{
LPTSTR customerName
LONG customerItems;
}
In C#, is correct the next wrapper?
[DllImport("Customers.dll")]
public static extern int GiveMeData(string sID, ref CustomerData pData);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct CustomerData
{
public string customerName;
public int customerItems;
}
If isn't correct, how is the best way for do it avoiding possibles heap corruptions, etc?
Thank you!!!!