关于VB.NET调用VB++制作的dll的函数问题,结构体地址参数
我用can总线跟一个仪表进行通讯,购买can总线转换器带的驱动dll里边有个函数,需要传递一个自定义结构的地址,不知道该怎么做,尝试了几个办法,都报错,请帮忙看看?VC中...
我用can总线跟一个仪表进行通讯,购买can总线转换器带的驱动dll里边有个函数,需要传递一个自定义结构的地址,不知道该怎么做,尝试了几个办法,都报错,请帮忙看看?
VC中结构声明
typedef struct _VCI_BOARD_INFO{
USHORT hw_Version;
USHORT
fw_Version;
USHORT dr_Version;
USHORT
in_Version;
USHORT irq_Num;
BYTE can_Num;
CHAR str_Serial_Num[20];
CHAR str_hw_Type[40];
USHORT
Reserved[4];
} VCI_BOARD_INFO,*PVCI_BOARD_INFO;
原型:
DWORD __stdcall VCI_InitCAN(DWORD DevType, DWORD DevIndex, DWORD
CANIndex, PVCI_INIT_CONFIG pInitConfig)
c++中调用是这么用Status =
VCI_InitCAN(DevType,DevIndex,CANIndex,&InitConfig);
但是VB.NET 2010中我应该怎么声明和调用呢?我用了以下方法,但是不对啊
声明:
Public Declare Function VCI_ReadBoardInfo Lib "Ginkgo_Driver.dll" (ByVal
DevType As Int32, ByVal DevIndex As Int32, ByRef Info As BOARD_INFO) As
int32
定义类型:
Structure BOARD_INFO '设备信息数据结构
Dim hw_Version As UShort
'Hx
Dim fw_Version As UShort 'Hx
Dim dr_Version As UShort
'Hx
Dim in_Version As UShort 'Hx
Dim irq_Num As
UShort
Dim can_Num As Byte
Dim str_Serial_Num() As Byte
Dim str_hw_Type() As Byte
Dim Reserved() As Byte
End Structure
调用:
ReDim CANinfo.str_hw_Type(40)
ReDim
CANinfo.str_Serial_Num(20)
ReDim
CANinfo.Reserved(4)
Status = VCI_ReadBoardInfo(CANType,
CInt(Me.ComboBox1.Text), CANinfo)
出现的错误是:
错误为: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
这个到底应该怎么做呢?谢谢
另外CHAR str_Serial_Num[20]; CHAR str_hw_Type[40]; USHORT Reserved[4]; 里边的方括号是啥意思?VB中的byte和int数组吗? 展开
VC中结构声明
typedef struct _VCI_BOARD_INFO{
USHORT hw_Version;
USHORT
fw_Version;
USHORT dr_Version;
USHORT
in_Version;
USHORT irq_Num;
BYTE can_Num;
CHAR str_Serial_Num[20];
CHAR str_hw_Type[40];
USHORT
Reserved[4];
} VCI_BOARD_INFO,*PVCI_BOARD_INFO;
原型:
DWORD __stdcall VCI_InitCAN(DWORD DevType, DWORD DevIndex, DWORD
CANIndex, PVCI_INIT_CONFIG pInitConfig)
c++中调用是这么用Status =
VCI_InitCAN(DevType,DevIndex,CANIndex,&InitConfig);
但是VB.NET 2010中我应该怎么声明和调用呢?我用了以下方法,但是不对啊
声明:
Public Declare Function VCI_ReadBoardInfo Lib "Ginkgo_Driver.dll" (ByVal
DevType As Int32, ByVal DevIndex As Int32, ByRef Info As BOARD_INFO) As
int32
定义类型:
Structure BOARD_INFO '设备信息数据结构
Dim hw_Version As UShort
'Hx
Dim fw_Version As UShort 'Hx
Dim dr_Version As UShort
'Hx
Dim in_Version As UShort 'Hx
Dim irq_Num As
UShort
Dim can_Num As Byte
Dim str_Serial_Num() As Byte
Dim str_hw_Type() As Byte
Dim Reserved() As Byte
End Structure
调用:
ReDim CANinfo.str_hw_Type(40)
ReDim
CANinfo.str_Serial_Num(20)
ReDim
CANinfo.Reserved(4)
Status = VCI_ReadBoardInfo(CANType,
CInt(Me.ComboBox1.Text), CANinfo)
出现的错误是:
错误为: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
这个到底应该怎么做呢?谢谢
另外CHAR str_Serial_Num[20]; CHAR str_hw_Type[40]; USHORT Reserved[4]; 里边的方括号是啥意思?VB中的byte和int数组吗? 展开
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询