简体   繁体   English

我如何调用一个使用NSIS系统插件导入另一个dll的dll

[英]How can i call a dll that import another dll using NSIS system plugin

I am newbie of NSIS installer. 我是NSIS安装程序的新手。 I gotta say NSIS deployment is awesome . 我得说NSIS的部署很棒。 but lately I am encountered a problem. 但是最近我遇到了一个问题。

I am using NSIS script to call let's say A.dll which compiled using Visual C++ and export some C functions. 我正在使用NSIS脚本来调用A.dll,该文件是使用Visual C ++编译并导出一些C函数的。 and A.dll import B.dll. 和A.dll导入B.dll。 So I extract them (A.dll and B.dll) to $PLUGINSDIR at the very beginning of installation. 因此,在安装之初,我将它们(A.dll和B.dll)提取到$ PLUGINSDIR中。

After that I call System::call to call let's say "test()" of A.dll. 之后,我调用System :: call来调用A.dll的“ test()”。 but it always return "error". 但它总是返回“错误”。 I also did a test removing import of B.dll and "test()" works and returns the value of what I expected. 我还做了一个测试,删除了B.dll的导入,“ test()”的工作原理并返回了我期望的值。

here is the code: 这是代码:

;extract dll file

InitPluginsDir

SetOutPath $PLUGINSDIR

File "A.dll"

File "B.dll"

........... ...........

;call it
code:
System::Call "$PLUGINSDIR\A::test() i.r0"

$0 return "error" $ 0返回“错误”

after removing import of B.dll and re-compile A.dll. 删除导入的B.dll后,重新编译A.dll。 test() works fine. test()可以正常工作。

Can anybody explain How can I call a dll that imports another dll using NSIS system plugin? 有人可以解释如何使用NSIS系统插件调用导入另一个dll的dll吗? Thanks in advance. 提前致谢。 sorry for the poor English. 对不起,英语不好。 hope you guys understand what I mean. 希望你们明白我的意思。

The loader cannot find B.dll so LoadLibrary (called by system.dll) on A.dll is going to fail. 加载程序找不到B.dll,因此A.dll上的LoadLibrary(由system.dll调用)将失败。

You can set the working directory: 您可以设置工作目录:

Push $outdir ; Save current, not required
SetOutPath $pluginsdir
System::Call "$PLUGINSDIR\A::test() i.r0"
pop $outdir
SetOutPath $outdir ; Restore

or you can load B.dll yourself: 或者您可以自己加载B.dll:

System::Call 'KERNEL32::LoadLibrary(t "$PLUGINSDIR\B.dll")i.s'
System::Call "$PLUGINSDIR\A::test() i.r0"
System::Call 'KERNEL32::FreeLibrary(is)'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM