VB怎么样调用VC做的DLL

来源:百度知道 编辑:UC知道 时间:2024/05/22 17:56:02
我在VC中写到:
extern "C" _declspec(dllexport) void EDcode(unsigned char *pdata, unsigned char *key, byte flag)
在VB中写到:
Private Declare Sub EDcode Lib "DES" (ByRef pdata As String, ByRef key As String, flag As Byte)
Private Sub Command1_Click()
Dim s As String
s = Text1.Text

Call EDcode(Text1.Text, Text2.Text, "E")

Text3.Text = Text1.Text
Text1.Text = s

End Sub

这怎么错了??
Text1.Text, Text2.Text是要输入变量

EDcode(Text1.Text, Text2.Text, "E") 中把前2个参数换成s1,s2,也就是字符串变量,并且在调用之前分配好空间,如下
dim s1 as string
dim s2 as string
dim i1 as byte
s1=space(333)'空间要足够大
s2=space(333)
i1=&h64
call EDcode(s1, s2, i1)
也许就好了。
===========
对于要输入变量必须先
s1=text1.text
s2=text2.text
再调用DLL函数。而且运算后的字符串不得比传进去的长。如果结果变长,必须以另外的变量带出来。
以上,如果还不行,则把VB函数中的ByRef换成byval试一下。我印像里VB和PB传参的方式不一样所以。