+ -
当前位置:首页 → 问答吧 → VB掉用VC++编写的DLL时参数传递老是出错

VB掉用VC++编写的DLL时参数传递老是出错

时间:2011-10-13

来源:互联网

如题,用VB2008调用VC++编写的DLL时参数传递老是出错。
用VB调用dll8.dll以实现加法运算并返回和,add函数参数传递时最后一个总是出错,传回的值为前两个数之和,并非3个数之和。

在dll8.cpp中代码如下:
_declspec(dllexport) void _stdcall add(int a,int b,int c)
{
int d; 
d=a+b+c;
char c1[8];
memset(c1,0,8);
itoa(d,c1,10);
MessageBox(NULL,c1,"三个数之和",MB_OK);
}


在dll8.def中代码如下:
LIBRARY "dll8"
EXPORTS
add

VB2008中代码:
Public Class Form1
  Private Declare Function add Lib "c:\dll8.dll" (ByVal a As Long, ByVal b As Long, ByVal c As Long) As Long
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  add(3, 4, 5)
  End Sub
End Class



由于是新手,故还没有分可以给

作者: lauxb   发布时间: 2011-10-13

Private Declare Function add Lib "c:\dll8.dll" (ByVal a As Long, ByVal b As Long, ByVal c As Long) As Long
最后As Long去掉

作者: omega_sta   发布时间: 2011-10-14

热门下载

更多