Search code examples
pluginsdllnsis

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


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.


Solution

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