问题描述
sdk里面c++中定义了这个函数:LONGNET_DVR_Login(char*sDVRIP,WORDwDVRPort,char*sUserName,char*sPassword,LPNET_DVR_DEVICEINFOlpDeviceInfo)。lpDeviceInfo:指向NET_DVR_DEVICEINFO结构的指针。在c#中我这样引用函数:publicstaticexternintNET_DVR_Login(stringsDVRIP,ushortwDVRPort,stringsUserName,stringsPassword,refNET_DVR_DEVICEINFOlpDeviceInfo);NET_DVR_DEVICEINFOnetDVRDeviceInfo1=newNET_DVR_DEVICEINFO();netDVRDeviceInfo1.sSerialNumber=newbyte[48];for(inti=0;i<48;i++)netDVRDeviceInfo1.sSerialNumber[i]=0;netDVRDeviceInfo1.AlarmInPortNum=4;netDVRDeviceInfo1.ChanNum=4;netDVRDeviceInfo1.DiskNum=4;netDVRDeviceInfo1.DVRType=DVS;netDVRDeviceInfo1.StartChan=1;netDVRDeviceInfo1.AlarmOutPortNum=4;userID=NET_DVR_Login("192.0.0.64",8000,"admin","12345",refnetDVRDeviceInfo1);程序运行到这里就不行了,请各位大侠帮忙解决一下
解决方案
解决方案二:
把struct改了下:[MarshalAs(UnmanagedType.ByValArray,SizeConst=48)]///<summary>序列号</summary>///publicByte[]sSerialNumber;过去了