Post by David NovoIf you can share how you programatically installed/uninstalled design
time IDE packages, that would be great.
Sharing the code is not something I can do, sorry. I can share the idea
behind the code, though.
As many people before me have already determined, there's currently no
official way of installing and uninstalling the packages from within an
IDE expert. So after careful consideration I decided to embark on a
difficult, trial-and-error-ridden path of simulating user input.
In a nutshell, this is what's required:
- Locate the action object that belongs to the "Component|Install
packages" menu item, and execute it
- Locate the list box component on the form that opens
- Locate the "Add", "Remove" and "OK" buttons on that same form
- Loop the list box items, calling "Remove" button's OnClick event
handler for each item
- Execute the "Add" button's OnClick event handler for every new package
to install
- Confirm the changes by executing "OK" button's OnClick handler
In reality, it was much more complicated, because initial action can
open different forms with different control structure and layout,
depending on whether there is a project open or not, and the type of the
active project (package/exe/dll).
Additionally, IDE pops up a dialog for every package about to be
removed. In order to hide that dialog, I had to figure out which API
was called (different on XP/Vista) and patch it with my own, which only
returned IDYES. Similar thing when installing packages - I had to patch
the TOpenDialog.Execute() so that it didn't really open the dialog, but
simply filled in the FileName property.
Oh, and that whole library path manipulation thing I initially asked
about? It turned out modifying paths through the official interfaces
didn't persist the changes. So I had to go through the UI for this,
too.
All in all, it took me 2 months or so of work, and I still have some
quirks to iron out (e.g. all other expert's shortcut key overrides stop
working after I run the expert). But it works pretty well in the end,
and that's what matters to me. :)
I'm aware I'll have to redo some of the UI-dependent things for Delphi
2008, but that's ok, since my users won't be switching to that version
for some months after it becomes available, so there'll be plenty time.
I probably haven't made anyone reading this too happy, but I still hope
it was helpful in some way. :)
--
Regards,
Aleksander Oven