引用一个动态库DLL,出参为unsigned char *XXX , 出参取出来就是乱码
给的动态库说明是 : int getRandom(int sConnect,int sRandomLen,unsigned char *random)
想问问, unsigned char *random 这个是传的是地址还是值。不懂C啊。
入参:sConnect ,sRandomLen
出参: random
我的VB代码:
'模块里声明
Public Declare Function getRandom Lib "XXX.dll" (ByVal sConnect As Long, ByVal sRandomLen As Long, ByVal random As String) As Long
'按键里的代码
dim handleID as long
dim ShuiJiShu as long
dim wholeStr as string
ShuiJiShu = 8 '临时随便赋值,约定的8个字节
handleID = 12321 '临时随便赋值,这个和问的应该无关
wholeStr = space(ShuiJiShu)
Select Case getRandom(handleID, ShuiJiShu, wholeStr)
Case 0
MsgBox wholeStr
MsgBox "成功读取"
Case -1
MsgBox "传入句柄有误"
Case -2
MsgBox "读取失败"
End Select
这样读出来的WholeStr就是乱码