依赖于其他DLL的插件DLL [英] Plugin DLLs that depend on other DLLs

查看:204
本文介绍了依赖于其他DLL的插件DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个DLL来插入另一个(第三方)应用程序。该DLL将需要依赖另一组DLL(由于许可证的原因,我不能静态链接)。

I am writing a DLL to plug into another (3rd party) application. The DLL will need to depend on another set of DLLs (for license reasons I cannot link statically).

我想我的DLL是xcopy-deployable任何目录。我也不想要添加这个目录到路径。

I would like my DLL to be "xcopy-deployable" to any directory. I would also like not to require adding this directory to the path.

如果我只是通常的方式构建DLL,Windows将拒绝加载DLL,因为它不能找到当前进程旁边的DLL。

If I just build the DLL the usual way, Windows will refuse to load the DLL, since it cannot find the DLLs next to the current process.

有帮助Windows定位DLL的好方法吗?

Are there any good options for helping Windows locate the DLL?

要回答一些问题:


  • DLL用C ++编写。

  • 额外的DLL是QT-dll。

  • 我想将额外的DLL放在同一文件夹作为我的插件DLL。我可以从 GetModuleFileName 获取该文件夹的名称。

  • 应用程序是Firefox,DLL是PKCS#11安全模块。

  • 应用程序使用DL​​L的完整路径加载DLL(用户在安装插件时提供它)。

  • 要求DLL

  • LoadLibrary 并且可能会导致卸载程序出现问题。 GetProcAddress 当然可以工作,但在我的情况下是不可行的。我使用数百,如果不是数千,其他DLL中的方法。我真的需要使用导入库。

  • The DLL is written in C++.
  • The extra DLLs are QT-dlls.
  • I would like to place the extra DLLs in the same folder as my plugin DLL. I can get the name of that folder from GetModuleFileName.
  • The application is Firefox, the DLL is a PKCS#11 security module.
  • The application loads the DLL using the full path to the DLL (the user supplies it when installing the plugin).
  • Requiring that the DLLs be placed in System32 or next to the application would work, but it is a bit messy and could cause problems with uninstallers.
  • LoadLibrary and GetProcAddress would of course work, but is not really feasible in my case. I am using hundreds, if not thousands, of methods in the other DLLs. I really need to use the import-libraries.

我曾经考虑过使用延迟加载的dll结合 SetDllDirectory 在DllMain中。有人试过这样的事吗?

I had thought about using delay-loaded dlls combined with SetDllDirectory in DllMain. Have anyone tried anything like this?

推荐答案

我可以想到3种方法。

I can think of 3 ways.


  1. 将dll放在与您的应用程序相同的文件夹中(您不能这样做。)

  2. 使用运行时链接。 LoadLibrary() GetProcAddress()

  3. 使用清单 http://msdn.microsoft.com/en-us/library/aa374182 (VS.85).aspx

  1. put the dlls in the same folder as your application (you cannot do this?)
  2. Use runtime linking. LoadLibrary() and GetProcAddress()
  3. Use a manifest http://msdn.microsoft.com/en-us/library/aa374182(VS.85).aspx

但是如果dll不在与.exe相同的文件夹中,你怎么知道它在哪里?忘记Windows不知道,你怎么知道?

But if the dll isn't in the same folder as the .exe, how are you going to know where it is? forget Windows not knowing, how do you know?

这篇关于依赖于其他DLL的插件DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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