2013-01-31 56 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