Question

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.

Was it helpful?

Solution 2

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

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top