从NSIS调用Inno安装插件

时间:2013-01-31 20:08:18

标签: inno-setup nsis

我正在尝试使用名为webcrtl的Inno安装插件(具有比nsweb更多功能的Web浏览器)。我试图用系统插件调用这个dll。

插件:

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

我得到一个空页......

1 个答案:

答案 0 :(得分:2)

DLL库函数名称区分大小写,并且您已使用别名而不是InnoSetup脚本中的函数名称。修改您的脚本,以便使用具有正确区分大小写的函数名称,您将使脚本正常工作。要导入的函数的名称是来自@关键字导入尾部的external字符之前的单词。例如,在以下函数导入示例中,导入函数的名称为newwebwnd,而不是NewWebWnd

function NewWebWnd(hWndParent: HWND; X, Y, nWidth, nHeight: Integer): HWND;
  external 'newwebwnd@files: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
相关问题