结构体c++定义为:
struct MyInfo
{
unsigned long nID;
unsigned long nParentID;
char strName[MAX_TEXT_LEN];
char strMemo[MAX_MEM_LEN];
}; 当结构体在定义的函数中作为形参定义时,如何调用?
如:
public bool GetMyInfoByID(UInt32 ID, ref MyInfo[] deviceStation, ref UInt32 pCount)如何调用?
struct MyInfo
{
unsigned long nID;
unsigned long nParentID;
char strName[MAX_TEXT_LEN];
char strMemo[MAX_MEM_LEN];
}; 当结构体在定义的函数中作为形参定义时,如何调用?
如:
public bool GetMyInfoByID(UInt32 ID, ref MyInfo[] deviceStation, ref UInt32 pCount)如何调用?
unsafe struct MyInfo
{
uint nID;
uint nParentID;
public fixed byte strName[MAX_TEXT_LEN];//MAX_TEXT_LEN用数值替换
public fixed byte strMemo[MAX_MEM_LEN];//MAX_MEM_LEN用数值替换
}public bool GetMyInfoByID(UInt32 ID, ref MyInfo[] deviceStation, ref UInt32 pCount)
这个函数最好有c++原形,第二个参数声明为ref MyInfo[] deviceStation的话,原形中应该是MyInfo**
GetMyInfoByID(IN unsigned long ID, OUT MyInfo deviceStation[], OUT unsigned int* pCount);c#定义为:
public bool GetMyInfoByID(UInt32 ID, ref MyInfo[] deviceStation, ref UInt32 pCount)
unsafe struct MyInfo
{
public uint nID;
public uint nParentID;
public fixed byte strName[MAX_TEXT_LEN];//MAX_TEXT_LEN用数值替换
public fixed byte strMemo[MAX_MEM_LEN];//MAX_MEM_LEN用数值替换
}
[DllImport("xxx")]
GetMyInfoByID(uint ID, MyInfo[] deviceStation, ref uint pCount);
//调用
MyInfo[] devicestation = new MyInfo[xxx];
uint id = xxx;
uint pcount = xxx;
GetMyInfoByID(id, devicestation, ref pcount);这样子