Can a DLL call / load another DLL?

I want to call some third-party DLL procedures from my own DLL. I just don't know how to do this in C ++.

+6
c ++ windows dll
source share
4 answers

You can use dynamic load-time layout or run-time dynamics linking in your DLL just like in an executable. The only limitation is not to call LoadLibrary from your DllMain function to avoid deadlocks.

+6
source share

LoadLibrary and GetProcAddress, but one of your friends ...

+2
source share

If this DLL has a .lib file, you simply add it to the linker input and statically put its functions. If not, there are some tools for creating a .lib file from a .dll.

You can also import functions dynamically using LoadLibrary and GetProcAddress .
MSDN says that you cannot call LoadLibrary from DllMain. But in most cases, nothing bad happens.

+2
source share

You usually contact the DLL through the export library in your project. Then, the DLL functions can be called by your program if the DLL is in the program path at runtime.

It is also possible (but much more work) to avoid the need to bind the time of the required functions by manually loading the DLL and obtaining the required function addresses, but this is not necessary if the third-party DLL supports the usual time-linking mechanisms.

+1
source share

All Articles