简体   繁体   English

如何将没有NSH文件的DLL插件添加到我的NSIS脚本中?

[英]How to add a DLL Plugin without NSH file into my NSIS script?

I'm using NSIS 2.46. 我正在使用NSIS 2.46。 Plugin I'm trying to use is HwInfo plug-in ( Official Link ). 我试图使用的插件是HwInfo插件( 官方链接 )。 The ZIP file comes with some source codes and a DLL file. ZIP文件附带一些源代码和DLL文件。 I put the HwInfo.dll inside \\NSIS\\Plugins directory. 我把HwInfo.dll放在\\NSIS\\Plugins目录下。 When adding a plugin, I'm supposed to !include the .nsh file as well, which HwInfo does not supply. 当添加一个插件,我应该!include.nsh文件以及,这HWINFO 提供。

I'm trying to analyze the client's harware before installing- 我正在尝试在安装之前分析客户端的硬件 -

Function .onInit
HwInfo::GetCpuSpeed

StrCpy $R0 $0
MessageBox MB_OK "You have a $0GHz CPU"

HwInfo::GetSystemMemory
StrCpy $0
MessageBox MB_OK "You have $0MB of RAM"
FunctionEnd

But the line HwInfo::GetCpuSpeed is 'invalid command' . 但是HwInfo::GetCpuSpeed'invalid command'

How do I use a plugin without a NSH file? 如何在没有NSH文件的情况下使用插件? And are there any alternatives? 还有其他选择吗?

Solved: 解决了:

I added !addplugindir "${NSISDIR}\\Plugins" at the very top of this script. 我在这个脚本的最顶部添加了!addplugindir "${NSISDIR}\\Plugins" This helped detect HwInfo.dll inside \\NSIS\\Plugins directory at compile-time. 这有助于在编译时检测\\NSIS\\Plugins目录中的HwInfo.dll

Not all plugins have a .nsh file but the wiki page usually tells you how to use a specific plugin. 并非所有插件都有.nsh文件,但维基页面通常会告诉您如何使用特定插件。

If you run makensis /V4 yourscript.nsi it will list all plugins and the functions they export, if your plugin is not on the list it is probably not in the correct directory. 如果你运行makensis /V4 yourscript.nsi它将列出所有插件及其导出的功能,如果你的插件不在列表中,它可能不在正确的目录中。 Make sure you put it in the correct directory or use !addplugindir ... 确保将其放在正确的目录中或使用!addplugindir ...

I know this question has an accepted answer, but for info for people using NSIS v3.x : 我知道这个问题有一个公认的答案,但对于使用NSIS v3.x的人的信息:

The plugin folder now has two sub-folders, one for ANSI and one for UNICODE, so you'd need to copy your plugins into ${NSISDIR}\\Plugins\\x86-ansi\\ and ${NSISDIR}\\Plugins\\x86-unicode\\ for the ANSI and UNICODE versions of the plugin dlls respectively. 插件文件夹现在有两个子文件夹,一个用于ANSI,一个用于UNICODE,因此您需要将插件复制到${NSISDIR}\\Plugins\\x86-ansi\\${NSISDIR}\\Plugins\\x86-unicode\\分别为插件dll的ANSI和UNICODE版本。

I'm guessing if you use the 64-bit NSIS port, you'd have \\x64-ansi\\ and \\x64-unicode subfolders too, but I've not checked that specifically. 我猜你是否使用64位NSIS端口,你也有\\x64-ansi\\\\x64-unicode子文件夹,但我没有具体检查。

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

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