NSIS插件功能无法识别

saz*_*azr 3 c++ dll nsis

我制作了一个非常简单的NSIS插件,其中包含一个功能.我已成功将Win32 DLL项目编译为DLL,然后将其复制到目录C:\ Program Files(x86)\ NSIS\Plugins

我的问题:当我创建从.dll调用函数的.nsi脚本时,我得到一个编译错误,说无效的命令:tbox :: myFunction

我究竟做错了什么?我是否需要将tbox.lib文件复制到NSIS目录中,或者创建要包含的tbox.nsh文件?

我的dll的名字是tbox.dll,我的nsi脚本在下面和下面是我的C++ DLL代码:

    !include MUI2.nsh
    !include WinMessages.nsh

    Name    "aa.nsi"
    OutFile "aa.exe"
    Caption "${^Name}"
    ShowInstDetails show
    !define MUI_CUSTOMFUNCTION_GUIINIT   MyGUIInit

    Section "Dummy"
        MessageBox MB_ICONINFORMATION|MB_OKCANCEL "dvkjdkj"
        tbox::myFunction "abc" "def"
    SectionEnd
Run Code Online (Sandbox Code Playgroud)

DLL代码:

#include "targetver.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#pragma comment(lib, "msimg32.lib")
#include <commctrl.h>
#include "TransparentCheckbox.h"
#include "NSIS/pluginapi.h"

HINSTANCE g_hInstance;
HWND g_hwndParent;
unsigned int g_stringsize;
stack_t **g_stacktop;
TCHAR *g_variables;

// To work with Unicode version of NSIS, please use TCHAR-type functions for accessing the variables and the stack.
HWND __declspec(dllexport) myFunction(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
{
  g_hwndParent=hwndParent;
  EXDLL_INIT();

  {
    TCHAR buf[1024];
    wsprintf(buf,TEXT("string_size=%d, variables=%s\n"), string_size, variables);
    MessageBox(g_hwndParent,buf,0,MB_OK);
  }

  return g_hwndParent;
}

BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
  g_hInstance = (HINSTANCE)hInst;
  return TRUE;
}
Run Code Online (Sandbox Code Playgroud)

And*_*ers 6

Makensis在编译时列出所有插件及其导出的函数.

如果未列出您的插件,则它不在正确的目录中或根本没有导出.如果它已列出但名称(tbox::_myFunctiontbox::myFunction@xyz)错误,那么您就会遇到装饰问题.您可以尝试extern "C" HWND __declspec(dllexport) __cdecl myFunction(...,如果这还不够,您可能需要一个.def文件.

您还可以使用Dependency Walker查看导出...