Import a DLL with C++ (Win32)


Question

How do I import a DLL (minifmod.dll) in C++ ?

I want to be able to call a function inside this DLL. I already know the argument list for the function but I don't know how to call it.

Is there a way of declaring an imported function in C++ like in C# ?

1
13
12/17/2009 3:36:53 PM

Accepted Answer

12
5/23/2017 12:17:41 PM

If the DLL includes a COM type library, you can use the #import statement as such:

#import dllname.dll

Otherwise, you'll need to link with an import library, and you'll need to provide a function prototype for your compiler. Typically the import library and a header file with the prototypes are provided by the DLL developer. If you're not, they can be very difficult to produce - unless you already know the argument list for the function, which you say you do. Instructions can be found here, amongst other places.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon