Load the same dll multiple times

leon22 picture leon22 · Sep 21, 2012 · Viewed 19.1k times · Source

I want to load the same dll e.g. Lib.dll multiple times!

-> need creating a new process (CreateProcess function) for every LoadLibrary!

Anyone have an example or some hints?!

Thx and greets

Answer

David Heffernan picture David Heffernan · Sep 21, 2012

It sounds like you want each instance of the DLL to have separate data segments. That's the only reason I can think of for the question.

The only way to achieve this is to make sure that each time you call LoadLibrary, the DLL has a different filename. Copy the DLL to a temporary file each time you need to load it, making sure that the name you use is different from any loaded instance of the DLL.

I echo the comments above that encourage you to re-design the system architecture.