Simple C++ Dynamic Link Library

I am trying to interface VBA with a C++ DLL. I am very new to C++ programming. I understand the declarations from the VBA side, but I am having a tough time authoring a simple C++ DLL. Could you help me with a small example of a C++ DLL with only one simple function? I can successfully build a DLL with a simple function, but I keep getting an error in VBA telling me that the DLL entry point can’t be found.

The first concern is name mangling required by C++ in order to support things like function overloading. If you use a tool to list the exported functions from your DLL, you’ll probably find they are different from the ones you expect. You could simply use the mangled names as they are exported, but it’s probably better to find a way to export “C” functions to avoid the C++ name mangling. The exact way to do this depends on your code (whether it’s classes or what exactly–note that cannot call C++ class members directly from VB).

The second concern is that, contrary to what you’ll find in the Microsoft documentation, you need to create a .DEF with an EXPORTS section that lists your exported symbols. This is required because even straight C functions will mangle the names slightly, and the .DEF file entries allow you to control this.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS