0

I have the following code which tries to detect Delphi installations using JclIDEUtils. To test it I set up two Virtual machines, both run Win 7 and in both systems I installed Delphi XE3 but in VM n1 I installed Jcl also, in VM n2 I didn't. Well, in n1 my little prog works fine and finds Delphi XE3, in n2 it doesn't! I tried to remote debug the program in both VMs but the only one thing I understood is that the object which instanciates the TJclBorRADToolInstallations class simply remains empty if Jcl is not installed.

This is my code in OnShow event of my form:

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;

Does someone know something about this issue?

Thanks in advance for any advice.

ain
  • 22,394
  • 3
  • 54
  • 74
Marco
  • 86
  • 1
  • 7
  • If you look at the source code, `TJclBorRADToolInstallations.Create;` simply creates an internal `TObjectList` and calls `ReadInstallations`, which just attempts to iterate through possible registry keys to see if Delphi, C++Builder, or RAD Studio is installed. There's no way it can fail and return `nil`; it may not find any installations, but it will still return an instance of the object. `FDelphiInstallations.Count` can be zero, which would stop your loop from executing. Have you looked at the registry itself (using RegEdit) on the machine that's failing? – Ken White May 27 '13 at 21:28
  • Also, when you did the installation, did you do it as an Admin (right-click and choose `Run as administrator` when starting the install) on the problem system? Did you install for a specific user, or for all users of the machine? – Ken White May 27 '13 at 22:08
  • Thanks, Ken for trying to help. The solution was very very simple and a little stupid: I has to run Delphi once to make JclIDEUtils detect that installation, even if I don't understand why this affect Delphi detection... – Marco May 28 '13 at 04:56

1 Answers1

1

Jcl failed to detect Delphi installation because I didn't run Delphi. Once I ran Delphi, JclIDEUtils detects its installation and my testing program succeed in displaying Delphi installation data.

Marco
  • 86
  • 1
  • 7
  • Ah, this makes sense. :-) After the installation is complete, the first run of the IDE configures the default entries, and if you didn't do that they wouldn't exist when JCLIDEUtils tries to access them. I didn't think of you not having run the IDE at least once. – Ken White May 28 '13 at 12:52
  • It was my intention to use that installation only for test my detection routine.:) – Marco Jun 01 '13 at 06:30