Inno Setup:组合框在下拉时立即关闭(启动应用程序)

Inno Setup: Combo box closing immediately on drop-down (which starts an application)

我正在获取应用程序池列表,然后使用应用程序池的名称填充组合框。问题是当 OnDropDown 事件被调用时,组合框打开几分之一秒然后立即关闭。它不会保留 "dropped down"。我确实在组合框中看到了所有应用程序池。这是我的代码:

function GetApplicationPoolList() : TArrayOfString;
var
  i, nExitCode: Integer;
  sFileLines: TArrayOfString;
  sTempFileName, sListAppPoolCmd: String;  
begin

    sListAppPoolCmd := ExpandConstant('{sys}') + '\inetsrv\appcmd list apppool /text:name'; 
    sTempFileName := ExpandConstant('{tmp}') + '\appPoolList.txt';
    if not ExecAppCmd(Format('%s > %s',[sListAppPoolCmd, sTempFileName]), nExitCode) then begin
      MsgBox('Could not get app pools', mbError, MB_OK);
    end else begin      
      LoadStringsFromFile(sTempFileName, sFileLines);
    end
    Result := sFileLines;
end;

// ==============================================

procedure OnAppPoolComboBoxDropDown(Sender: TObject);
var
  sAppPoolList: TArrayOfString;
  i: Integer;
begin

  // Clear existing
  appPoolComboBox.Items.Clear;
  // Populate the combo box with the application pools
  sAppPoolList := GetApplicationPoolList;  

  For i := 0 to GetArrayLength (sAppPoolList) - 1 do
    begin
      // ComboBox with Application Pool Names   
      appPoolComboBox.Items.Add(sAppPoolList[i]);      
    end;
  appPoolComboBox.ItemIndex := 0;
end;


function ExecAppCmd(params :String; nExitCode: Integer) :Boolean;
var
  execSuccessfully :Boolean;
  resultCode :Integer;
begin
  execSuccessfully := Exec('cmd.exe', '/c ' + '' + ' ' + params, '', SW_HIDE, ewWaitUntilTerminated, resultCode); 
  nExitCode := resultCode;   
  Result := execSuccessfully and (resultCode = 0);
end;

我不确定这里发生了什么。任何建议表示赞赏。

编辑:ExecAppCmd 似乎是问题所在,将其注释掉会使组合框正常运行...虽然不确定原因

下拉菜单关闭可能是因为组合框在应用程序启动时暂时失去焦点。

我认为在下拉菜单上调用应用程序是一种不好的做法,因为这会花费时间并且会破坏用户体验。更早地填充组合框,例如 CurPageChanged