none
怎样使用vb2010调用vc6的dll,有原代码和错误信息。 RRS feed

  • 问题

  • 错误信息:对 PInvoke 函数“海康7804录像机测试!WindowsApplication1.Form1::NET_DVR_Login_V30”的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配。

    Public Class Form1
        Public Structure NET_DVR_DEVICEINFO_V30
            Public sSerialNumber As Byte
            Public byAlarmInPortNum As Byte
            Public byAlarmOutPortNum As Byte
            Public byDiskNum As Byte
            Public byDVRType As Byte
        End Structure

        Declare Auto Function NET_DVR_Init Lib "hcnetsdk.dll" () As Boolean
        Declare Auto Function NET_DVR_GetSDKVersion Lib "hcnetsdk.dll" () As Integer
        Declare Auto Function NET_DVR_Login_V30 Lib "hcnetsdk.dll" (ByVal ip As String, ByVal port As Integer, ByVal uname As String, ByVal pwd As String, ByVal info As NET_DVR_DEVICEINFO_V30) As Long
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            NET_DVR_Init()
            TextBox1.Text = NET_DVR_GetSDKVersion()

    上面2个调用成功

            Dim devinfo1 As New NET_DVR_DEVICEINFO_V30 

    这个调用不成功,出错。
            MsgBox(NET_DVR_Login_V30("192.168.1.112", 8000, "admin", "admin", devinfo1))
        End Sub
    End Class

    请高手解答。

    2012年5月23日 5:05