【问题标题】:Calling a simple VC DLL from VB6从 VB6 调用一个简单的 VC DLL
【发布时间】:2009-04-27 18:13:58
【问题描述】:

我有一个用 VC6 编写的具有一个功能的简单 DLL:

__declspec(dllexport) int myfunc(long a, unsigned char *b, unsigned char *c, unsigned char *d, unsigned char *e)

我从 vb6 调用它:

Declare Function myfunc Lib "mylib.dll" (ByVal a As Long, ByVal b As String, ByVal c As String, ByVal d As String, ByVal e As String) As Long

....

dim a as long
dim b as string
dim c as string
dim d as string
dim e as string
dim r as long

r=myfunc(a,b,c,d,e)

我收到“错误的 dll 调用约定”错误,但我不知道为什么。有什么想法吗?

【问题讨论】:

    标签: vb6 dllimport


    【解决方案1】:

    一般来说,'bad DLL...' 意思是它所说的。 VB6 对其调用的任何外部函数都需要 _stdcall 约定(如 Win API)。

    尝试将__stdcall 添加到 C 函数原型中,看看会发生什么。

    【讨论】:

      【解决方案2】:

      查看 Paul Caton 的 Universal DLL 函数调用程序:

      http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=70195&lngWId=1

      它将允许您从 VB6 调用几乎任何类型的函数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-05-20
        • 1970-01-01
        • 2011-12-19
        • 2012-03-04
        • 2010-09-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多