Can't find DLL entry point

隐身守侯 提交于 2019-12-10 18:45:56

问题


I have been trying to call a DLL function in my VBA project but I keep getting this error message:

Run-time error '453': Can't find DLL entry point "CheckStatus" in "Power.dll"

Here is the definition for the DLL in the C++ file:

#define CLASS_DECLSPEC extern "C" __declspec(dllexport)

CLASS_DECLSPEC int __stdcall CheckStatus();

And here is how I'm trying to declare it and call it in VBA:

Public Declare Function CheckStatus Lib "Power.DLL" () As Long

Dim test As Long
test = CheckStatus

And then when I run it received the aforementioned error message.

Does anyone know how to fix this? Thanks.


回答1:


using this MSDN article, I would try this method of declaring the function:

Public Declare Function CheckStatus Lib "Power.DLL" Alias "_CheckStatus@0" () As Long



回答2:


This has to do with name mangling (even with extern "C").
Look at what export is really in the DLL, a guess would be either _CheckStatus or _CheckStatus@0.
To force the name to be as-is, make a .def file in your project with the content:

EXPORTS
    CheckStatus=CheckStatus


来源:https://stackoverflow.com/questions/13980912/cant-find-dll-entry-point

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!