簡體   English   中英

NSIS:使用帶空格的絕對路徑調用 DLL function

[英]NSIS: calling DLL function with System::Call using absolute path with blanks

我正在嘗試從 myfile.dll 調用 function int MyFunction()並在消息框中顯示它的返回值。

到目前為止有效的方法:

  SetOutPath "$TEMP"
  File "myfile.dll"
  ;File "System.dll" for some time I thought one needs to copy the plugin, but that's not needed
  MessageBox MB_OK "$0"
  System::Call '$TEMP\myfile.dll::MyFunction()i.r0'
  MessageBox MB_OK "$0"
  System::Free 0

一旦我用$INSTDIR替換$TEMP ,它就不再起作用了。 實際上它確實如此,只要$INSTDIR不包含空格,不幸的是C:\Program Files (x86)會...

有一次,我從這個 NSIS 論壇帖子中發現這種行為是一個錯誤,即this . 我並沒有真正弄清楚它的狀態。

我還嘗試了兩個頁面中都顯示的kernel32::LoadLibrarykernel32::GetProcAddress的解決方法,但我不知道在System::Call "::$1(the usual parameters here)"行中使用什么。

那么我現在如何調用 MyFunction() 呢?

系統插件現在支持路徑中的引號:

System::Call '"$InstDir\MyLibrary.dll"::MyFunction(i 42)'

如果 DLL 依賴於同一目錄中的其他 DLL,但單個 DLL 應該在沒有它的情況下工作,則需要調用 KERNEL32::AddDllDirectory。

使用 kernel32::GetProcAddress 時參數相同,只是路徑和 function 名稱改為直接地址。

最終修復它的是將$INSTDIR添加到搜索路徑中,如this answer中所建議的那樣

 System::Call 'KERNEL32::AddDllDirectory(w "$INSTDIR")'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM