Load a DLL More Than Once?

后端 未结 3 1362
醉酒成梦
醉酒成梦 2021-01-04 21:44

I\'m using the LoadLibrary function to load a DLL in Windows. My question is this: If I call this method more than once for the same DLL, do I get handles to different insta

3条回答
  •  悲哀的现实
    2021-01-04 21:53

    The MSDN documentation states:

    The system maintains a per-process reference count on all loaded modules. Calling LoadLibrary increments the reference count. Calling the FreeLibrary or FreeLibraryAndExitThread function decrements the reference count. The system unloads a module when its reference count reaches zero or when the process terminates (regardless of the reference count).

    So it would appear that loading the module more than once (without matching calls to FreeLibrary) will return the same handle.

提交回复
热议问题