c++的结构转到c#
sdk里面c++中定义了这个函数:LONG NET_DVR_Login(char *sDVRIP,WORD wDVRPort,char *sUserName,char *sPassword ,LPNET_DVR_DEVICEINFO lpDeviceInfo)。lpDeviceInfo: 指向NET_DVR_DEVICEINFO结构的指针。
在c#中我这样引用函数: public static extern int NET_DVR_Login(string sDVRIP, ushort wDVRPort, string sUserName, string sPassword, ref NET_DVR_DEVICEINFO lpDeviceInfo);
NET_DVR_DEVICEINFO netDVRDeviceInfo1=new NET_DVR_DEVICEINFO ();
netDVRDeviceInfo1.sSerialNumber = new byte[48];
for (int i = 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", ref netDVRDeviceInfo1);
程序运行到这里就不行了,请各位大侠帮忙解决一下 --------------------编程问答-------------------- 把struct改了下:
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 48)]
///<summary>序列号</summary>///
public Byte[] sSerialNumber;
过去了
补充:.NET技术 , C#