ERROR 453 -Can't find Entry Point in C++ dll (x64 bit)

Using Visual Studio 2017 community on Windows 10- 64 bits.

I am a C++ beginner and I have written a small C++ 64 bit dll so I can use it in (excel 2010 64bit)VBA .. This dll simply exports a very simple function "square" as described in this short video: https://www.youtube.com/watch?v=7aDAyf72S7o

I followed the steps correctly and the C++ project compiled corectly.

cpp file
1
2
3
4
5
  double _stdcall square (double & x)
{

return x*x;
}



Def file :
1
2
LIBRARY squareDll
EXPORTS square


Problem:
When I call this from excel vba as shown below, I get Run time Error 453 "Can't find DLL Entry Point ...

This is my VBA code in Excel:

1
2
3
4
5
Declare PtrSafe Function Square Lib "C:\Users\Info-Hp\documents\visual studio 2017\Projects\square\x64\Debug\squareDll.dll" _ (ByRef x As Double) As Double

Sub Test()
MsgBox Square(2)
End Sub


When I open this squareDll C++ dll in Dependency Walker, it shows a red module that says : "Could not find the section that owns the Import Directory"

Can anybody tell me what the problem is?

Thank you.
Last edited on
Thank you Thomas1965.

I'll take a look at the suggested link and post back later .
Hi, I am back again.

I took a long look at the link and the info is quite complicated for me as a beginner

I followed the suggestions made by the user Malick and this is what I did :

1- Removed the Def file from my project.
2- In the cpp file, I edited my code as follows :
1
2
3
4
5
6
7
8
#define EXPORT comment(linker, "/EXPORT:" __FUNCTION__ "=" __FUNCDNAME__)

double _stdcall square(double & x)
{
	#pragma EXPORT
	return x*x;
	
}


The project compiled correctly!

However, when calling the 'Square' function from my excel VBA, I still get the same 453 error.

Did I write the EXPORT MACRO shown at the top properly ? Do I have to leave the 'linker' word literally as well as the EXPORT word as they are or do I need to replace them with the actual linker and export names ?

Please can anybody help me ?

Thank you.
I think the correct solution is actually using a .def file. Using __stdcall will lead again to the problem with name mangling. Dependy walker shows then _square@8 or sth. which isn't a correct name in VBA.

In this tutorial he show how to call a DLL from VB, so maybe it will work with VBA as well.
I don't have Office so I can't test it.

https://www.codeproject.com/Articles/6243/Step-by-Step-Calling-C-DLLs-from-VC-and-VB-Part
Hi Thomas1965,

Sorry to respond so late .

The info in the codeproject link turned out to be very useful .

I eventually managed to compile a working C++ 64bit dll that exports two functions which respectively set and remove a windows CBT hook using (SetWindowsHookEx) .. The purpose of this hook is to monitor the creation of any window whose Class name is #32770 and destroy them as soon as they are created in Excel.

Later on, I 'il post here the entire C++ project code and all the steps I followed in case anybody needs that info in the future.

Again thank you very much for your assistance.

LATE EDIT:
One could install this CBT hook directly in Excel VBA without the need of an external dll but if the VBA project is accidently reset (by pressing the IDE Stop button) or if an unhandled error occurs while the hook is installed, the whole excel application crashes!

On the other hand, setting the hook inside a dll is IDE safe as it prevents the above mentioned problem.
Last edited on
Topic archived. No new replies allowed.