gpt4 book ai didi

c++ - 从 VBA 调用 DLL

转载 作者:太空宇宙 更新时间:2023-11-04 12:27:14 30 4
gpt4 key购买 nike

我需要使用 VBA 从 Access 调用 DLL 函数。 DLL函数的原型(prototype)是

int __stdcall myFunction(const char* data,
int rows, int cols, int sl, int fullsize,
double aspect_ratio,
double y,
void** ppResult);

我在Access中声明的那个:

Private Declare Function DllImport_myFunction _
Lib "myFunctionDLL.dll" _
Alias "myFunction" _
(ByVal data As String, _
ByVal rows As Long, _
ByVal cols As Long, _
ByVal sl As Long, _
ByVal fullsize As Long, _
ByVal aspectRatio As Double, _
ByVal y As Double, _
ByRef handle As Long)

当我尝试从 Access 调用时,Access 因 Access 冲突而崩溃。我在DLL函数的第一条语句下了一个断点,但没有命中。

声明是否错误?

最佳答案

你错过了返回

Private Declare Function DllImport_myFunction Lib "myFunctionDLL.dll" Alias "myFunction" _
(ByVal data As String, _
ByVal rows As Long, _
ByVal cols As Long, _
ByVal sl As Long, _
ByVal fullsize As Long, _
ByVal aspectRatio As Double, _
ByVal y As Double, _
ByRef handle As Long
) As Long

并且可能需要添加 extern "C"以避免 mangling。

关于c++ - 从 VBA 调用 DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1556240/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com