我有一个使用此签名的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
答案 0 :(得分:0)
我刚刚意识到我没有官方的答案。
这是函数声明,包括对我的外部函数的调用:
Public Sub ExecuteRead(ByVal pstruct As LongPtr, structSize As Integer)
SFetch1 dataCur, ByVal pstruct, structSize
我是如何从主程序中调用它的:
obj.ExecuteRead VarPtr(returnGrp), LenB(returnGrp)