3
votes

I work on a system in Delphi XE that has code broken out into about 20 BPLs, about 10 of which are design-time packages. I have multiple versions of the system in various states of development at any given time. There is a file folder structure for each version. When I need to switch from one working on one version to another, I need to switch the BPLs that are installed in Delphi from one folder to the other.

I do this fairly often so I tried to create a procedure to make this switch as quickly as possible, which works fine most of the time. In Registry Editor, I delete my BPLs from Delphi's Known Packages and then I run a .reg file that adds the entries for the new folder. Then I edit the Windows Path environment variable to point to the new folder. Usually, when I then restart Delphi I will have the correct packages installed in the IDE.

But sometimes it gets into a state and I get this:

"The program can't start because General90.bpl is missing from your computer."

Now I know without a doubt that file is NOT missing from my computer. And I know it is on my path. This is a base package required by all the others. I could understand getting this error if other packages are trying to install and this one isn't found. But this file is exactly where it's supposed to be, and it always is.

I can go back to Registry Editor, delete my BPL entries and restart Delphi. If I try Component -> Install Packages and add the BPLs, often this works, but just as often I get the same "can't find the BPL" error.

At this point I will open a .groupproj file that I have containing all the packages, right-click and install each of the design-time packages in Project Manager one-by-one. This will work 99% of the time. After that I can close Delphi and reopen it over and over without any problems. Until the next time I need to switch folders.

Can anyone tell me what installing the packages one-by-one in the Project Manager does that adding the entries directly to the registry in Known Packages does not do?

1
You should probably accomplish this by starting Delphi in a new environment, which generates a new dedicated registry key. I don't recall how, but it consists of passing a parameter into Delphi when opening, which kicks it into a separate portion of the registry.Jerry Dodge
You might consider a different approach. Instead of modifying the "Known Packages" key, setup different base keys for different configurations, each one with its own list of packages to load, and then start the IDE using the /r <regkey> command line switch to specify which configuration to use. Also, try using SysInternals Process Monitor to see where exactly the IDE is looking for the BPLs when the error occurs.Remy Lebeau
^ Yeah, what he said.Jerry Dodge
We have a command line tool that updates the registry in the manner you describe. I have noticed that at some point the command line compiler stopped seeing our changes until the IDE was opened for the first time. We still don't know why we just started opening the IDE once after editing the registry and before running our build scripts.Mark Elder
Thanks for telling me about the /r <regkey> command line switch. I will try that as soon as I have a chance. Don't I still have to deal with the Windows Path environment variable? How does it determine where to find the runtime-only packages since they don't appear in the registry?Ron Schuster

1 Answers

0
votes

Instead of modifying the registry, I would modify the file structure. In Windows you have something called JUNCTION POINTS, which is very much like symbolic links on UNIX.

I would make a structure something like this (the actual directories could be anywhere, just using C:\BPLs as an example, and the various configurations could even be in completely different places in the directory structure, or even on different physical disks/partitions):

C:\BPLs\CFG1
C:\BPLs\CFG2
C:\BPLs\CFG3

and then have a JUNCTION POINT that points to one of these, via the command

JUNCTION C:\BPLs\Active C:\BPLs\CFG1

using This program

You can then create a .BAT file that calls these two lines:

JUNCTION /D C:\BPLs\Active
JUNCTION C:\BPLs\Active C:\BPLs\CFG1

for each of the configurations to switch among them. In your DELPHI you'd just load the files from C:\BPLs\Active and also let the PATH point there, and let the JUNCTION POINT take charge of selecting which one it is.