我做了一個非常簡單的NSIS插件,它有一個功能。我已經成功編譯的Win32 DLL項目成DLL然後將其複製到該目錄C:\ Program Files文件(x86)的\ NSIS \插件NSIS插件功能不被識別
我的問題:當我創建.nsi腳本調用一個函數從DLL我得到一個編譯錯誤說無效的命令: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;
}
你能看到的導出函數從其他工具,如取決於? – leppie 2012-07-11 05:31:08
@leppie yes我可以看到函數和它的名字,但由於某種原因它有點奇怪嗎?myFunction @@ YAPAUHWND __ @@ PAU1 @ HPADPAPAU_stack_t @@ PAUextra_parameters @@@ Z – 2012-07-11 06:26:12
您需要將它導出爲C函數。給出的答案是正確的。使用'extern「C」'。 – leppie 2012-07-11 08:05:23