我制作了一个非常简单的 NSIS 插件,其中包含一个功能。我已成功将 Win32 DLL 项目编译成 DLL,然后将其复制到目录C:\Program Files (x86)\NSIS\Plugins
我的问题:当我创建从 dll 调用函数的 .nsi 脚本时,我收到一个编译错误,提示 Invalid command: 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
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;
}