0

我有以下代码尝试使用 JclIDEUtils 检测 Delphi 安装。为了测试它,我设置了两个虚拟机,都运行 Win 7,在两个系统中我都安装了 Delphi XE3,但在 VM n1 中我也安装了 Jcl,在 VM n2 中我没有。好吧,在 n1 中,我的小程序工作正常,找到了 Delphi XE3,在 n2 中却没有!我尝试在两个 VM 中远程调试程序,但我唯一理解的一件事是,如果未安装 Jcl,实例化 TJclBorRADToolInstallations 类的对象将保持为空。

这是我在表单的 OnShow 事件中的代码:

procedure TForm1.FormShow(Sender: TObject);
var
  I, X: Integer;
  TN, SubTn: TTreeNode;
  IconIndex: Integer;
begin
  FDelphiInstallations := TJclBorRADToolInstallations.Create;
  for I := 0 to FDelphiInstallations.Count - 1 do
  begin
    IconIndex := ilDelphiIcons.AddIcon(GetSmallIcon(FDelphiInstallations[I].IdeExeFileName));
   TN := tvDisplay.Items.AddChild(nil, FDelphiInstallations[I].Name);
   TN.ImageIndex := ilDelphiIcons.Count - 1;
   TN.SelectedIndex := ilDelphiIcons.Count - 1;
   with tvDisplay.Items do
   begin
    SubTn := AddChild(TN, 'Description: ' + FDelphiInstallations[I].Description);
    SubTn.ImageIndex := 0;
    SubTn := AddChild(TN, 'Root directory: ' + FDelphiInstallations[I].RootDir);
    SubTn.ImageIndex := 0;
    SubTn := AddChild(TN, 'Projects directory: '+ FDelphiInstallations[i].DefaultProjectsDir);
    SubTn.ImageIndex := 0;
    SubTn := AddChild(TN, 'Common Projects directory: '+ FDelphiInstallations[i].CommonProjectsDir);
    SubTn.ImageIndex := 0;
    SubTn := AddChild(TN, 'Executable File name: '+ FDelphiInstallations[i].IdeExeFileName);
    SubTn.ImageIndex := 0;
    SubTn := AddChild(TN, 'Build number: '+ FDelphiInstallations[i].IdeExeBuildNumber);
    SubTn.ImageIndex := 0;
    SubTn := AddChild(TN, 'VersionNumberStr='+ FDelphiInstallations[i].VersionNumberStr);
    SubTn.ImageIndex := 0;
    SubTn := AddChild(TN, 'Registry key='+ FDelphiInstallations[i].ConfigDataLocation);
    SubTn.ImageIndex := 0;
    for X := 0 to FDelphiInstallations[i].IdePackages.Count - 1 do
    begin
      SubTn := AddChild(TN, 'Description: ' + FDelphiInstallations[I].IdePackages.PackageFileNames[X]);
      SubTn.ImageIndex := 0;
    end;
  end;
end;
end;

有人知道这个问题吗?

提前感谢您的任何建议。

4

1 回答 1

1

Jcl 未能检测到 Delphi 安装,因为我没有运行 Delphi。一旦我运行 Delphi,JclIDEUtils 就会检测到它的安装,并且我的测试程序会成功显示 Delphi 安装数据。

于 2013-05-28T04:58:38.017 回答