【问题标题】:Inno Setup Compiler: How to use a constant from Setup region within a event methodInno Setup Compiler:如何在事件方法中使用 Setup 区域中的常量
【发布时间】:2013-10-10 13:05:46
【问题描述】:

inno setup compiler 内有如下区域:

[Setup]
DefaultDirName={pf}\cow1


function NextButtonClick(CurPageID: Integer): Boolean;
var
  ExecInfo: TShellExecuteInfo;
begin
  Result := True;

  if CurPageID = wpFinished then
  begin
    ExecInfo.cbSize := SizeOf(ExecInfo);
    ExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS;
    ExecInfo.Wnd := 0;
    ExecInfo.lpFile := DefaultDirName + '\{#Exewampmanager}';
    ExecInfo.nShow := SW_HIDE;

    if ShellExecuteEx(ExecInfo) then
    begin
      if WaitForSingleObject(ExecInfo.hProcess, 3000) = WAIT_TIMEOUT then
      begin
        TerminateProcess(ExecInfo.hProcess, 666);
        MsgBox('You just killed a little kitty!', mbError, MB_OK);
      end
      else
        MsgBox('The process was terminated in time!', mbInformation, MB_OK);
    end;
  end;
end;

如何在函数内使用 [Setup] 区域中的 DefaultDirName const?

ps:

ExecInfo.lpFile := DefaultDirName + '\{#Exewampmanager}'; 不起作用

【问题讨论】:

  • ExpandConstant('{app}') + '\{#Exewampmanager}' - 在脚本中 DefaultDirName 变为 {app} 常量。你可以像上面那样使用它。
  • 现在这个应该可以了
  • ExecInfo.lpFile := ExpandConstant('{app}') + '\{#Exewampmanager}; 应该可以正常工作。
  • OT:如果它直到那个时候才终止,你将在 3 秒后杀死那个 wamp。你知道的,对吧?
  • 请不要用“Windows 安装程序”标记 inno-setup 问题。这两种技术无关。

标签: inno-setup


【解决方案1】:

你必须扩展常量,比如:

ExpandConstant('{app}\myapp.exe')

{app} 是最终目标文件夹

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 2011-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-29
    • 1970-01-01
    相关资源
    最近更新 更多