怎样用VB程序调用带参数的VC程序的DLL函数?

tangliang01 2008-10-29 09:48:01
本人的程序如下

WIN32动态连接库:
// test.cpp : Defines the entry point for the DLL application.
//

#include "StdAfx.h"
#include <stdio.h>
#include "test.h"
void succode(double *Source1,char *Source2);

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}

EXPORT BOOL CALLBACK test(double Source1[],char *Source2)
{
succode(Source1,Source2);
return TRUE;
}

void succode(double *Source1,char *Source2)
{
int i;
for(i=0;i<6;i++)
printf("%20.12f",Source1[i]);
for(i=0;i<6;i++)
printf("%20.12f",Source2[i]);
}


//test.h

#define EXPORT extern "C" __declspec(dllexport)

EXPORT BOOL CALLBACK test(double Source[],char *Source2);



VB程序:

Private Declare Function test Lib "F:\Debug\test.dll" (ByRef Source1() As Double, ByRef Source2 As String) As Boolean
Private Sub Command1_Click()
Dim want(1 To 6) As Double, strWant As String

want(1) = 1: want(2) = 2: want(3) = 3: want(4) = 4: want(5) = 5: want(6) = 6:
strWant = "Basic"
If test(want, strWant) = True Then
End
Else
RT = MsgBox("Dll函数错误", vbOKOnly)
End
End If
End Sub

调试VB出现如下错误

实时错误 '453'

找不到DLL入口点 test in F:\Debug\test.dll

请教各位问题在那里
...全文
66 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tangliang01 2008-11-01
  • 打赏
  • 举报
回复
test.h里不是加了#define EXPORT extern "C" __declspec(dllexport)
palmax 2008-10-30
  • 打赏
  • 举报
回复
c++导出时加上 extern "C"
Sandrer 2008-10-30
  • 打赏
  • 举报
回复
__declspec(dllexport)

用这个关键字来定义输出函数,它会把函数名更改掉滴~

你用__stdcall来定义输出函数
然后创建一个*.def文件用作输入
sys0004 2008-10-29
  • 打赏
  • 举报
回复
用depends查看下你的DLL是否有导出的test函数。

http://www.dependencywalker.com/depends22_x86.zip

15,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧