Search code examples
c++vbadllentry-point

Can't find DLL entry point


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.


Solution

  • 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