i486
i486

Reputation: 6563

Multiple LoadLibrary for copies of the same DLL

I have a DLL which is not thread-safe and must be used by multiple threads. I am not sure how Windows detects loaded DLL-s, whether it is by full file path or by DLL/Module name. If the file path is used, I think it may be possible to copy the DLL in separate files for each thread, e.g. MyLib1.dll, MyLib2.dll, MyLib3.dll and load them with LoadLibrary.

Upvotes: 0

Views: 931

Answers (1)

David Heffernan
David Heffernan

Reputation: 613053

So long as you use the full absolute file name when you call LoadLibrary, and so long as these absolute file names are different, then you can load multiple instances.

Personally if it were me I would create the thread, and then copy the DLL to a temporary folder naming it <threadID>.dll. That will guarantee uniqueness of name.

Upvotes: 2

Related Questions