Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

plugins

dll

nsis

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.

like image 719
Samik Sengupta Avatar asked Aug 15 '13 17:08

Samik Sengupta


2 Answers

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

like image 99
Anders Avatar answered Sep 24 '22 20:09

Anders


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.

like image 45
Nick Shaw Avatar answered Sep 22 '22 20:09

Nick Shaw