views:

1306

answers:

1

Inno Setup is a nice easy to use installer. It is rated high in this stackoverflow question. I have a need to install a plugin to a folder relative to the installation folder of a 3rd Party application. It isn't obvious from the docs how to do this.

+3  A: 

You can find the answer to how to optionally install a file using a registry entry in the documentation and in sample code but it may not be obvious so here is some example script snippets using an Adobe Premiere Plugin as an example:

The keys steps are:

1) use the Check: parameter

2) Write a function that calls RegQueryStringValue and parse the path to construct the relative plugin folder destination

3) use {code:} to call a function to return the destination folder

//
// Copy my plugin file to the Premiere Plugin folder, but only if Premiere is installed.
//
[Files]
Source: "C:\sourceFiles\myplugin.prm";  Check: GetPremierePluginDestination; DestDir: "{code:PluginDestination}"; Flags: ignoreversion overwritereadonly

[Code]

var sPluginDest : String;

//
// Search for the path where Premiere Pro was installed.  Return true if path found.
// Set variable to plugin folder
//

function GetPremierePluginDestination(): Boolean;
var
  i:      Integer;
  len:    Integer;

begin
  sPluginDest := '';

  RegQueryStringValue( HKLM, 'SOFTWARE\Adobe\Premiere Pro\CurrentVersion', 'Plug-InsDir', sPluginDest );
  len := Length(sPluginDest);
  if len > 0 then
  begin
    i := len;
    while sPluginDest[i] <> '\' do
      begin
        i := i-1;
      end;

    i := i+1;
    Delete(sPluginDest, i, Len-i+1);
    Insert('Common', sPluginDest, i);
  end;
  Result := len > 0;
end;

//
//  Use this function to return path to install plugin
//
function PluginDestination(Param: String) : String;
begin
   Result := sPluginDest;
end;

I'm not a Pascal programmer so any suggestions on making GetPremiereDestination more efficient are welcome.

AlanKley