andychen20121130
V2EX  ›  问与答

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

  •  
  •   andychen20121130 · Sep 15, 2017 · 2264 views
    This topic created in 3341 days ago, the information mentioned may be changed or developed.

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

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

    4 replies  •  2017-09-18 14:09:23 +08:00
    momo1999
    momo1999
    Sep 15, 2017 via Android
    1
    如果有互相依赖会死锁,没有依赖就加载吧
    ysc3839
    ysc3839
    Sep 15, 2017 via Android
    2
    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
    andychen20121130
    OP
    Sep 18, 2017
    3
    @shuax 没有相互依赖。
    andychen20121130
    andychen20121130
    OP
    Sep 18, 2017
    4
    @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).
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1601 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 12:50 · PVG 20:50 · LAX 04:50 · JFK 07:50
    ♥ Do have faith in what you're doing.