[英]Call dll function in NSIS and return boolean
我試圖在dll中調用該函數,但失敗了。 這是我的NSIS腳本:
!include "LogicLib.nsh"
Section "MyTest"
Strcpy $0 "abc"
System::Call 'MyDll::FindSomething(t, b) i(r0, false) .r1'
${If} $1 == true
MessageBox MB_OK "1"
${ElseIf} $1 == false
MessageBox MB_OK "0"
${EndIf}
SectionEnd
FindSomething函數應返回布爾值true或false。 我的腳本的結果執行后什么也不顯示。
您沒有提取MyDll.dll嗎?
false
不是受支持的關鍵字,請使用0
。
沒有C / C ++聲明,很難給出完整的示例,但是我可以嘗試:
Section
InitPluginsDir
File "/oname=$PluginsDir\MyDll.dll" "c:\myfiles\MyDll.dll" ; Extract
System::Call 'KERNEL32::AddDllDirectory(w "$PluginsDir")' ; Make sure we are allowed to load from here
System::Call 'KERNEL32::LoadLibrary(t "$PluginsDir\MyDll.dll")p.r9'
MessageBox mb_OK "Loaded MyDll at address $9" ; This should not be 0!
; bool __cdecl FindSomething1(char* p1, bool p2):
StrCpy $0 "abc"
System::Call 'MyDll::FindSomething1(m r0, b 0)b.r1 ?c'
MessageBox mb_OK "Returned $1"
; int WINAPI FindSomething2(LPTSTR p1, BOOL p2):
StrCpy $0 "abc"
System::Call 'MyDll::FindSomething2(t r0, i 0)i.r1'
MessageBox mb_OK "Returned $1"
; ${If} $1 <> 0 ...
System::Call 'KERNEL32::FreeLibrary(p r9)'
SectionEnd
只有非常新版本的System插件支持b
類型,但無論如何您都可以在大多數地方使用i
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.