首页 > 解决方案 > 为什么 vba 不能成功调用用 c++ 编写的 dll?

问题描述

我得到了一个 c++ 演示,它成功调用了用 c++ 编写的 API,现在正在尝试从 excel VBA 调用这些 API。我做了很多研究,但仍然无法将它们联系在一起。

基本上在 demo 'TapQuote.h 中有一个这样的 API(TapQuoteAPI.dll) 导出函数

TAP_DLLEXPORT const TAPICHAR *TAP_CDECL GetTapQuoteAPIVersion();

在演示 c++ 解决方案(TapQuoteAPI_Demo)中,我在 demo.cpp 中包含“TapQuote.h”,

cout<<GetTapQuoteAPIVersion()<<endl; _ 调用成功,结果打印。

但是当谈到在excel vba中调用这个函数时,我一直失败。

我尝试像这样在 excel 中直接使用 TapQuoteAPI.dll,但没有用。

Declare Function GetTapQuoteAPIVersion Lib "D:\Proejct\WIN32\TapQuoteAPI.dll" () As String

然后我还尝试使用来自 TapQuoteAPI_Demo.dll 的 deFile.def 构建另一个 dll 函数,因为我在 c++ 演示中成功调用了它。

Declare Function GetTapQuoteAPIVersion Lib "D:\Proejct\WIN32\TapQuoteAPI_demo.dll" () As String

也失败了。有人可以为我点亮一些灯吗?

标签: c++excel

解决方案


推荐阅读