I am preparing an installer (Inno Setup) to install my component package into Delphi XE without having to manually fiddle in the IDE.
I need to modify the Delphi library path, for example to delete part of it (for example, xxx;MyOldPath;yyy) and insert a new path, xxxx;MyNewPath;yyyy. Is there a preferred way of doing this or will I have to write a utility to do it?
Thanks
Modifying the path is basic string manipulation: you read the current path from the registry, manipulate it to suit your needs, write it back.
You can probably write an Inno Setup script function so you don’t have any external dependencies. Or write a Delphi DLL that’s used from Inno Setup’s script so it’ll be easier to debug.
Edit
Here’s a modified version of a routine I’m actually using in production. It’ll read the whole list of paths from either the
Search Pathregistry value or theBrowsing Path(any other path for that matter), potentially remove some paths, and add some paths if they don’t already exist.From Delphi code I can call the routine like this, to make sure the latest search path to a given library is installed:
Notice both the
ToRemoveandToAdd. I can safely specify a search path in both Remove and Add lists: Paths are only removed if they match "Remove" criteria but aren’t also in the "ToAdd" list. Also note thePathMatchesRemoveCriteriafunction.You can probably modify the code to work straight from the InnoScript itself, or you can put the code in a DLL and use the DLL from the installer. The DLL variant has the merit of being easily debugged in Delphi and very easy on Inno itself; The Inno variant has the merit of not having external dependencies, but the code would need to be adapted and debugged.