在Delphi中加载同一个DLL的两个实例 [英] Load two instances of the same DLL in Delphi

查看:136
本文介绍了在Delphi中加载同一个DLL的两个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题:我想创建同一个DLL的两个单独的实例。

Here's my problem: I would like to create two separate instances of the same DLL.

以下内容不起作用,因为Handle1和Handle2将获得相同的地址

The following doesn't work because Handle1 and Handle2 will get the same address

  Handle1 := LoadLibrary('mydll.dll');
  Handle2 := LoadLibrary('mydll.dll');

以下工作原理,但是我必须制作一个DLL的副本并将其重命名为别的东西(这似乎有点愚蠢)

The following works, but I have to make a copy of the DLL and rename it to something else (which seems a bit silly)

  Handle1 := LoadLibrary('mydll.dll');
  Handle2 := LoadLibrary('mydll2.dll');

有没有办法只有一个DLL文件,但加载了几个实例?

Is there a way to have only one DLL file, but load several instances of it?

推荐答案

我不认为这是可能的。

你必须写一个加载dll的.exe。然后,您可以跨多个进程(.exe),并且每个进程将运行其自己的dll实例。您必须使用IPC(进程间通信)技术与.exes进行通信。当然可以,但并不完全没有脑子。

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.

这篇关于在Delphi中加载同一个DLL的两个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆