Load two instances of the same DLL in Delphi

蹲街弑〆低调 提交于 2019-12-04 11:21:07

I don't think that's possible.

You'd have to write a .exe which loads the dll. Then you can span multiple processes (the .exe), and each will run its own instance of the dll. You'd have to use IPC (inter process communication) techniques to communicate with the .exes. Certainly doable, but not exactly a no-brainer.

It won't work with LoadLibrary because Windows checks whether the dll has already been loaded and will return the same handle again and again.

I have got some code that was originally meant to load a dll from a resource bound to the executable but I guess it would also be possible to do the same for a memory area which was filled with the content of a file. I can't see any reason why it would not work twice, but I have not tested it.

You can find it here: http://svn.berlios.de/viewvc/dzchart/utilities/dzLib/trunk/src/u_dzResourceDllLoader.pas?view=markup

It is part of my library dzlib which is available under the MPL.

Jeroen Wiert Pluimers

Windows XP introduced side-by-side execution for Win32 DLL's (these guys know a lot about it).

With a lot of hoops you can now:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!