dll 中加载另一个 dll 文件的问题

2017-09-15 17:17:09 +08:00
 andychen20121130

看了网上都说不建议在 dllmain 中使用 loadLibrary,freeLibrary 函数。

如果不在 dllmain 加载,应该在什么地方加载呢?

1476 次点击
所在节点    问与答
4 条回复
shuax
2017-09-15 18:58:22 +08:00
如果有互相依赖会死锁,没有依赖就加载吧
ysc3839
2017-09-15 22:02:55 +08:00
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682583(v=vs.85).aspx
Calling functions that require DLLs other than Kernel32.dll may result in problems that are difficult to diagnose. For example, calling User, Shell, and COM functions can cause access violation errors, because some functions load other system components. Conversely, calling functions such as these during termination can cause access violation errors because the corresponding component may already have been unloaded or uninitialized.
andychen20121130
2017-09-18 14:07:35 +08:00
@shuax 没有相互依赖。
andychen20121130
2017-09-18 14:09:23 +08:00
@ysc3839 在几个步骤中加载吗?

A process loads the DLL (DLL_PROCESS_ATTACH).
The current process creates a new thread (DLL_THREAD_ATTACH).
A thread exits normally (DLL_THREAD_DETACH).
A process unloads the DLL (DLL_PROCESS_DETACH).

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/391022

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX