Re: Object reference error
Which object are you getting the error on?
Most likely the error occurs when trying to assign a value to the "sSerialNumber()" variable.
When declaring arrays in Structures, you can't assign an initial size to the array. As in:
Code:
Public sSerialNumber(4) as Btye
Before assigning a value to the "aSerialNumber()" variable, try ReDim-ing it.
As in:
Code:
Public LDD As New LPNET_DVR_DEVICEINFO
ReDim LDD.sSerialNumber(4)
NET_DVR_Login(IPAdress, DVRPort, UserName, Password, LDD)
Re: Convert c++ to vb.net
I suspect the error may lie in the code where you are calling the function. Could you show it?
Re: Convert c++ to vb.net
Thanks everyone
I find the soultion already.
VB Code:
<StructLayout(LayoutKind.Sequential)> _
Structure NET_DVR_DEVICEINFO
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=48)> _
Dim sSerialNumber() As Byte
Dim byAlarmInPortNum As Byte
Dim byAlarmOutPortNum As Byte
Dim byDiskNum As Byte
Dim byDVRType As Byte
Dim byChanNum As Byte
Dim byStartChan As Byte
End Structure
<DllImport("HCNetSDK.dll", CharSet:=CharSet.Ansi)> _
Public Shared Function NET_DVR_Login(ByVal sDVRIP As String, _
ByVal wDVRPort As Short, ByVal sUserName As String _
, ByVal sPassword As String, ByRef deviceinfo As NET_DVR_DEVICEINFO) As Integer
End Function