本文介绍了在Inno Setup中单击“完成"按钮后,根据自定义复选框运行文件和程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Inno Setup的完成页面中创建了一些自定义复选框.例如,启动应用程序,打开文本文件等.

I have created some custom checkboxes in the finished page of Inno Setup.For example launching an app, opening a text file etc.

当用户单击完成"按钮时,我需要我选中这些复选框并执行所需的任何操作.如何在Inno Setup中做这样的事情?

I need when the user clicks on the finish button I check those checkboxes and do whatever that is needed. How can I do such a thing in Inno Setup?

这是代码:

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpFinished then
  begin
       Launch := TNewCheckBox.Create(WizardForm);
       Launch.Parent := WizardForm;
       Launch.Left := WizardForm.ClientWidth - 350;
       Launch.Top := WizardForm.CancelButton.Top;
       Launch.Width := 120;
       Launch.Height := WizardForm.CancelButton.Height;
       Launch.Caption := 'Launch';
  end;
end;

推荐答案

NextButtonClick事件处理程序,测试您的复选框是否已选中并采取相应措施.

In NextButtonClick event handler, test if your checkbox is checked and act accordingly.

function NextButtonClick(CurPageID: Integer): Boolean;
var
  ResultCode: Integer;
  Path: string;
  Message: string;
begin
  if CurPageID = wpFinished then
  begin
    if Launch.Checked then
    begin
      Path := ExpandConstant('{app}\MyProg.exe');
      if ExecAsOriginalUser(Path, '', '', SW_SHOW, ewNoWait, ResultCode) then
      begin
        Log('Executed MyProg');
      end
        else
      begin
        Message := 'Error executing MyProg: ' + SysErrorMessage(ResultCode);
        MsgBox(Message, mbError, MB_OK);
      end;
    end;
  end;
  Result := True;
end;

这篇关于在Inno Setup中单击“完成"按钮后,根据自定义复选框运行文件和程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 02:55