2013-01-31 112 views
1

我正在嘗試使用名爲webcrtl的Inno安裝插件(具有比nsweb更多功能的Web瀏覽器)。我試圖用系統插件調用這個dll。從NSIS調用Inno安裝插件

插件:

http://restools.hanzify.org/article.asp?id=90

這就是我想,沒有成功:

Page custom Pre 

Var hCtl_dialog 
Var browser 
Function Pre 
    InitPluginsDir 
    File "${BASEDIR}/Plugins/inno_webctrl_v2.1/webctrl.dll" 

    nsDialogs::Create 1018 
    Pop $hCtl_dialog 

    System::Call "webctrl::NewWebWnd(i $HWNDPARENT, i 100, i 100, i 200, i 200) i .s" 
    Pop $browser 
    System::Call "webctrl::DisplayHTMLPage(i '$browser', t 'http://www.google.com/') i .s" 
    Pop $R0 

    nsDialogs::Show $hCtl_neoinstaller_genericcustom 
FunctionEnd 

我得到一個空白頁...

+2

只是一個幾個筆記,因爲我不知道NSIS。 1)['WebCtrl'](http://restools.hanzify.org/inno/webctrl/inno_webctrl_v2.1.zip)是ANSI庫(非Unicode),因爲它顯然在['import']中顯示(對於使用'PChar'的InnoSetup,InnoSetup的ANSI版本中的ANSI字符的指針是什麼。 2)你確定你想通過'$ HWNDPARENT'作爲網頁控制的父母嗎?這不應該是'$ hCtl_dialog'嗎? 3)最後,檢查函數的返回值。 – TLama

+0

1)沒關係,我是unis ANSI版本的NSIS。 2)我先嚐試了'$ hCtl_dialog',但沒有成功。使用$ HWNDPARENT是一個反覆試驗。 3)我會做的,謝謝! :-D –

回答

2

DLL庫函數名稱區分大小寫,並且您使用別名代替InnoSetup腳本中的函數名稱。修改您的腳本,以便使用具有適當區分大小寫的函數名稱,並讓您的腳本正常工作。要導入的函數的名稱是來自external關鍵字導入尾部的@ char之前的單詞。例如,下面的函數導入樣品中,導入函數的名稱是newwebwnd,不NewWebWnd

function NewWebWnd(hWndParent: HWND; X, Y, nWidth, nHeight: Integer): HWND; 
    external '[email protected]:webctrl.dll stdcall'; 

所以你的情況,修改函數名稱下面的方式,你應該罰款:

然後
... 
    System::Call "webctrl::newwebwnd(i $hCtl_dialog, i 0, i 0, i 150, i 150) i.s" 
    Pop $browser 
    System::Call "webctrl::displayhtmlpage(i $browser, t 'http://www.google.com/') b.s" 
    Pop $R0 
... 

的安裝頁面內拉伸WebCtrl控制整個腳本可能是這樣的:

!include "nsDialogs.nsh" 

OutFile "Setup.exe" 
RequestExecutionLevel user 
InstallDir $DESKTOP\WebBrowserSetup 

Page directory 
Page custom InitializeWebBrowserPage 

var hDialog 
var hBrowser 
Function InitializeWebBrowserPage 

    InitPluginsDir 
    SetOutPath $PLUGINSDIR 
    File "webctrl.dll" 

    nsDialogs::Create 1018 
    Pop $hDialog 

    ; get the page client width and height 
    System::Call "*(i, i, i, i) i.r0" 
    System::Call "user32::GetClientRect(i $hDialog, i r0)" 
    System::Call "*$0(i, i, i.r1, i.r2)" 
    System::Free $0 

    ; create a web browser window stretched to the whole page client rectangle 
    ; and navigate somehwere; note that you should add some error handling yet 
    System::Call "webctrl::newwebwnd(i $hDialog, i 0, i 0, i $1, i $2) i.s" 
    Pop $hBrowser 
    System::Call "webctrl::displayhtmlpage(i $hBrowser, t 'http://www.google.com') b.s" 
    Pop $R0 

    nsDialogs::Show 

FunctionEnd 

Section "" 
SectionEnd 
+0

令人驚歎!你救了我很多頭痛! :-) –

+0

很高興能幫到你! :-) – TLama