开发者

Can a DLL call/load another DLL? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

开发者_开发问答

Closed 8 years ago.

Improve this question

I want to call some third party DLL routines from my own DLL. I'm just not sure how to do that in C++.


You can use load-time dynamic linking or run-time dynamic linking in your DLL in the same way as in the executable. The only restriction is not to call LoadLibrary from your DllMain function to avoid deadlocks.


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


If this dll has .lib file, you just add it to linker input and import its functions statically. If it don't, there are some tools to generate .lib file from .dll.

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


Typically you link to the DLL via an export library in your project. Then the DLL functions can be called by your program, provided the DLL is in the program's path at runtime.

It's also possible (but a lot more work) to avoid link-time resolution of the required functions by manually loading the DLL and getting the required function addresses, but that should not be necessary if the third-party DLL supports the usual link-time mechanisms.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜