调用VC写的DLL有关问题,求教
调用VC写的DLL问题,求教
请高手指教!
下面是函数原型
BOOL cnTest(int number, UCHAR* Msg,UCHAR* ResultMsg)
其中的ResultMsg用于保存返回的结果.
在VB.net中应该如何声明呢?
这样对吗?
Private Declare Function cnTest Lib "aTest.dll " (ByVal number As Integer, ByRef Msg As String, ByRef ResultMsg As String) As Boolean
------解决方案--------------------
去掉ByRef
传入用string
传出的用StringBuilder,并分配购空间
StringBuilder sb = new StringBuilder(255)
------解决方案--------------------
帮忙顶
------解决方案--------------------
试试这样
Private Declare Function cnTest Lib "aTest.dll " (ByVal number As Integer, ByVal Msg() As Byte, ByVal ResultMsg() As Byte) As Boolean
Dim byte_ResultMsg(1023) as Byte
cnTest(number,Encoding.Default.GetBytes(msg),byte_ResultMsg)
Dim str_ResultMsg As String = Encoding.Default.GetString(byte_ResultMsg)
完了以后可能要去掉后面的Chr(0)字符
------解决方案--------------------
Private Declare Function cnTest Lib "aTest.dll " (ByVal number As Integer, ByRef Msg As Byte, ByRef ResultMsg As Byte) As Boolean
dim msg(1023) as Byte
dim resmsg(1023) as Byte
cnTest(number,msg(0),resmsg(0))
请高手指教!
下面是函数原型
BOOL cnTest(int number, UCHAR* Msg,UCHAR* ResultMsg)
其中的ResultMsg用于保存返回的结果.
在VB.net中应该如何声明呢?
这样对吗?
Private Declare Function cnTest Lib "aTest.dll " (ByVal number As Integer, ByRef Msg As String, ByRef ResultMsg As String) As Boolean
------解决方案--------------------
去掉ByRef
传入用string
传出的用StringBuilder,并分配购空间
StringBuilder sb = new StringBuilder(255)
------解决方案--------------------
帮忙顶
------解决方案--------------------
试试这样
Private Declare Function cnTest Lib "aTest.dll " (ByVal number As Integer, ByVal Msg() As Byte, ByVal ResultMsg() As Byte) As Boolean
Dim byte_ResultMsg(1023) as Byte
cnTest(number,Encoding.Default.GetBytes(msg),byte_ResultMsg)
Dim str_ResultMsg As String = Encoding.Default.GetString(byte_ResultMsg)
完了以后可能要去掉后面的Chr(0)字符
------解决方案--------------------
Private Declare Function cnTest Lib "aTest.dll " (ByVal number As Integer, ByRef Msg As Byte, ByRef ResultMsg As Byte) As Boolean
dim msg(1023) as Byte
dim resmsg(1023) as Byte
cnTest(number,msg(0),resmsg(0))