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