Hi, this is my first post here. First of all, sorry for my English.

I'm having problems with the code below, is an SDK for a DVR security camera, the example that comes with SDK are in VB6 and I am trying to use in VB.Net.
That's the original code:

Code:
'API initialization statement
Public Declare Function CLIENT_Init Lib "dhnetsdk.dll" (ByVal fDisConnect As Long, _
ByVal wDVRPort As Long) As Long

'Login API
Public Declare Function CLIENT_Login Lib "dhnetsdk.dll" _
(ByVal pchDVRIP As String, _
ByVal wDVRPort As Long, _
ByVal pchUserName As String, _
ByVal pchPassword As String, _
lpDeviceInfo As NET_DEVICEINFO, _
ByRef error As NET_RET_ERROR) As Long

'Logout device
Public Declare Function CLIENT_Logout Lib "dhnetsdk.dll" (ByVal lLoginID As Long) As Long

'Realplay API
Public Declare Function CLIENT_RealPlay Lib "dhnetsdk.dll" _
(ByVal lLoginID As Long, ByVal nChannelID As Long, ByVal hwnd As Long) As Long

Public Declare Function CLIENT_RealPlayEx Lib "dhnetsdk.dll" _
(ByVal lLoginID As Long, ByVal nChannelID As Long, ByVal hwnd As Long, _
ByVal rType As Long) As Long

'Stop Realplay
Public Declare Function CLIENT_StopRealPlayEx Lib "dhnetsdk.dll" (ByVal lLoginID As Long) As Long

Public Declare Sub CLIENT_Cleanup Lib "dhnetsdk.dll" ()

'Alarm Liten API
Public Declare Function CLIENT_StartListen Lib "dhnetsdk.dll" _
(ByVal lLoginID As Long) As Long

'Mess callback API
Public Declare Function CLIENT_SetDVRMessCallBack Lib "dhnetsdk.dll" (ByVal fMessCallBack As Long, _
ByVal dwUser As Long) As Long

Public Type NET_DEVICEINFO      '设备的结构体
    sSerialNumber As String * 48
    byAlarmInPortNum As Byte
    byAlarmOutPortNum As Byte
    byDiskNum As Byte
    byDVRType As Byte
    byChanNum As Byte
End Type

Public Type NET_RET_ERROR
    errcode As Integer
End Type

'初始化回调函数
Public Sub IniFunc(ByVal lLoginID As Long, ByVal pchDVRIP As Long, ByVal nDVRPort As Long, ByVal dwUser As Long)
Form1.Text1.Text = lLoginID
End Sub

'消息回调函数

Public Sub MessFunc(ByVal lCommand As Long, _
  ByVal lLoginID As Long, ByVal pBuf As Long, _
  ByVal dwBufLen As Long, ByVal pchDVRIP As Long, _
  ByVal nDVRPort As Long, ByVal dwUser As Long)


    Form1.Text1.Text = lLoginID
    Form1.Text2.Text = pBuf
    Form1.Text3.Text = pchDVRIP

End Sub


'回调函数指针传入
Public Function PtrToLong(ByVal func As Long) As Long
    PtrToLong = func
End Function
I have "converted" to this one:

Code:
Public Class Form1
    Public Declare Function CLIENT_Init Lib "dhnetsdk.dll" (ByVal fDisConnect As Integer, _
ByVal wDVRPort As Long) As Long



    'Login API
    Public Declare Function CLIENT_Login Lib "dhnetsdk.dll" (ByVal pchDVRIP As String, ByVal wDVRPort As Long, ByVal pchUserName As String, ByVal pchPassword As String, lpDeviceInfo As NET_DEVICEINFO, ByRef err As NET_RET_ERROR) As Long

    'Logout device
    Public Declare Function CLIENT_Logout Lib "dhnetsdk.dll" (ByVal lLoginID As Long) As Long

    'Realplay API
    Public Declare Function CLIENT_RealPlay Lib "dhnetsdk.dll" _
    (ByVal lLoginID As Long, ByVal nChannelID As Long, ByVal hwnd As Long) As Long

    Public Declare Function CLIENT_RealPlayEx Lib "dhnetsdk.dll" _
    (ByVal lLoginID As Long, ByVal nChannelID As Long, ByVal hwnd As Long, _
    ByVal rType As Long) As Long

    'Stop Realplay
    Public Declare Function CLIENT_StopRealPlayEx Lib "dhnetsdk.dll" (ByVal lLoginID As Long) As Long

    Public Declare Sub CLIENT_Cleanup Lib "dhnetsdk.dll" ()

    'Alarm Liten API
    Public Declare Function CLIENT_StartListen Lib "dhnetsdk.dll" (ByVal lLoginID As Long) As Long

    'Mess callback API
    Public Declare Function CLIENT_SetDVRMessCallBack Lib "dhnetsdk.dll" (ByVal fMessCallBack As Long, _
    ByVal dwUser As Long) As Long

    Public Structure NET_DEVICEINFO
        Public sSerialNumber As String
        Public byAlarmInPortNum As Byte
        Public byAlarmOutPortNum As Byte
        Public byDiskNum As Byte
        Public byDVRType As Byte
        Public byChanNum As Byte
    End Structure

    Public Structure NET_RET_ERROR
        Public errcode As Integer
    End Structure


    Public Sub IniFunc(ByVal lLoginID As Long, ByVal pchDVRIP As Long, ByVal nDVRPort As Long, ByVal dwUser As Long)
        MessageBox.Show(lLoginID)
    End Sub



    Public Sub MessFunc(ByVal lCommand As Long, _
      ByVal lLoginID As Long, ByVal pBuf As Long, _
      ByVal dwBufLen As Long, ByVal pchDVRIP As Long, _
      ByVal nDVRPort As Long, ByVal dwUser As Long)


        MessageBox.Show(lLoginID)
        MessageBox.Show(pBuf)
        MessageBox.Show(pchDVRIP)

    End Sub


    Public Function PtrToLong(ByVal func As Long) As Long
        PtrToLong = func
    End Function

    Private bInited, bout As Boolean
    Private hLoginId, hMonitorId As Long
    Private err As NET_RET_ERROR
    Private devInfo As NET_DEVICEINFO
    Private dd, longinid As Long

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        bInited = CLIENT_Init(PtrToLong(AddressOf IniFunc), 0)
    End Sub
End Class
But I'm having a problem with this line> "bInited = CLIENT_Init (PtrToLong (AddressOf IniFunc), 0)".

An error appears: "Address of expression can not be converted to 'Long' because 'Long' is not a delegate type".

I did a search, I have not found a solution, or at least I did not understand the answer.

I saw that maybe this is a difference between VB6 and VB.Net or something.

Could someone help me?