C#调用VC的DLL参数是自定义类型指针的问题
ffb 2004-08-09 01:21:38 C++中的结构如下:
typedef struct commconf
{
short total;
short level;
unsigned short tcp_port;
short cli_num;
int BW;
int BL;
unsigned short cliport[CLINUM_MAX];
unsigned char cli[CLINUM_MAX][20];
} COMMCONF;
函数定义:
int (*F_InitVp)(COMMCONF *pConf);
我改写在C#的如下:
const int CLINUM_MAX =30;
public struct commconf
{
public short total;
public short level;
public ushort tcp_port;
public short cli_num;
public int BW ;
public int BL;
ushort [] cliport;
byte [,] cli;
public commconf(int intParam)
{
total=0;
level=0;
tcp_port=0;
cli_num=0;
BW=0;
BL=0;
cliport=new ushort[CLINUM_MAX];
cli=new byte[CLINUM_MAX,20];
}
};
函数定义:
[DllImport("vp.dll", EntryPoint="InitVp",CharSet=CharSet.None)]
public static extern int F_InitVp(out commconf pConf);
调用的时候就内存溢出了,请问对于这种自定义的类型参数,并且参数还要返回值(一般传递的是指针),应该怎么处理?