1

我有一个使用此签名的 dll:

SFetch(cursor As Integer, pstruct As Any, size As Integer) As Integer

我可以用简单的变量来调用它,比如Integer使用自定义类型的更复杂的变量。

我想创建一个接收参数并将其发送到 dll 的函数,我尝试了不同的解决方案,但总是有错误。

在所有情况下,我都是这样称呼它的:

Dim val As Integer
...
.ExecuteRead val, LenB(val)

Public Sub ExecuteRead(ByVal pstruct, structSize As Integer)
        SFetch1 c, pstruct, structSize

返回Null而不是一个值


Public Sub ExecuteRead(pstruct, structSize As Integer)
        SFetch1 c, pstruct, structSize

回来Variable uses an Automation type not supported in Visual Basic


Public Sub ExecuteRead(pstruct As Variant, structSize As Integer)
        SFetch1 c, pstruct, structSize

回来Variable uses an Automation type not supported in Visual Basic


Public Sub ExecuteRead(pstruct As Object, structSize As Integer)
        SFetch1 c, pstruct, structSize

无法调用函数ByRef argument type mismatch


Public Sub ExecuteRead(pstruct As Any, structSize As Integer)

甚至不会编译,Syntax error

4

1 回答 1

1

刚刚意识到我没有官方答案,所以就在那里。

这是函数声明,包括对我的外部函数的调用:

Public Sub ExecuteRead(ByVal pstruct As LongPtr, structSize As Integer)
    SFetch1 dataCur, ByVal pstruct, structSize

我是如何从我的主程序中调用它的:

obj.ExecuteRead VarPtr(returnGrp), LenB(returnGrp)
于 2018-11-12T15:53:57.037 回答