How to add a DLL Plugin without NSH file into my NSIS script?
Asked Answered
P

2

5

I'm using NSIS 2.46. Plugin I'm trying to use is HwInfo plug-in (Official Link). The ZIP file comes with some source codes and a DLL file. I put the HwInfo.dll inside \NSIS\Plugins directory. When adding a plugin, I'm supposed to !include the .nsh file as well, which HwInfo does not supply.

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'.

How do I use a plugin without a NSH file? And are there any alternatives?

Solved:

I added !addplugindir "${NSISDIR}\Plugins" at the very top of this script. This helped detect HwInfo.dll inside \NSIS\Plugins directory at compile-time.

Plexiform answered 15/8, 2013 at 17:54 Comment(1)
The plugin directory changed in NSIS 3.0 but since you did not specify a version I'm assuming you are using NSIS 2.46...Interlocutory
I
12

Not all plugins have a .nsh file but the wiki page usually tells you how to use a specific plugin.

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. Make sure you put it in the correct directory or use !addplugindir...

Interlocutory answered 15/8, 2013 at 18:57 Comment(1)
Thank you. I added !addplugindir "${NSISDIR}\Plugins" at the very top of the script and it worked like a charm!Plexiform
C
7

I know this question has an accepted answer, but for info for people using 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.

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.

Cassandracassandre answered 2/5, 2014 at 9:37 Comment(3)
What if the plugin only has one dll? How do we know if it's ANSI or UNICODE?Inebriate
You'd have to check with the plugin's creator, I guess. It's not easy to tell from the file itself.Cassandracassandre
I just learned the hard way that you need to have the Unicode True|False statement before the !addplugindir statement.Bobker

© 2022 - 2024 — McMap. All rights reserved.