VB调用C动态库,程序崩溃,高手帮忙!特急
最近做项目用VB做了个管理界面,需要调用C程序编写的DLL函数,遇到问题如下:
C函数原型:
__declspec (dllexport) int WINAPI pwdencypt (char *merchant, char *oper, char *pos_id, char *inword, char *outword)
VB申明如下:
Declare Function pwdencypt Lib "pinkey.dll " (ByVal merchant As String, ByVal oper As String, ByVal pos_id As String, ByVal inword As String, outword As string) As Long
VB中调用如下:
Dim var1 As String
Dim var2 As String
Dim var3 As String
Dim var4 As String
Dim var5 As String*16
var1 = "105150252711111 "
var2 = "8112 "
var3 = "1112 "
var4 = "111111 "
Dim ret As Long
ret = pwdencypt(var1, var2, var3, var4, var5)
......
VB调用该函数希望得到var5的值,但程序执行到这里VB就崩溃了。我在函数pwdencypt中打印了日志,显示出var1, var2, var3, var4传入的值都正确,var5所对应的outword也有值了,而且都正确。但是VB总是崩溃,也检查了var5的长度,应该足够了。网上找了很多例子,都没有找到解决方案。求高手帮忙看看,在此谢谢了。
[解决办法]
你就是要地址传递,返回得到的值,我以前做过的,你去看看我的贴子
http://topic.csdn.net/T/20060307/16/4598697.html
http://topic.csdn.net/T/20060305/22/4594229.html