如何使用 Inno Setup 根據註冊表項選擇在文件夾中安裝插件/文件? (How do I use Inno Setup to optionally install a plugin/file in a folder based on a registry entry?)


問題描述

如何使用 Inno Setup 根據註冊表項選擇在文件夾中安裝插件/文件? (How do I use Inno Setup to optionally install a plugin/file in a folder based on a registry entry?)

Inno Setup 是一個很好用的安裝程序。它在 this stackoverflow question 中的評分很高. 我需要將插件安裝到與 3rd 方應用程序的安裝文件夾相關的文件夾中。從文檔中看如何做到這一點並不明顯。


參考解法

方法 1:

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.

(by AlanKleyAlanKley)

參考文件

  1. How do I use Inno Setup to optionally install a plugin/file in a folder based on a registry entry? (CC BY‑SA 2.5/3.0/4.0)

#inno-setup #scripting #registry






相關問題

如何從 InitializeWizard 中更改嚮導頁面的名稱和描述? (How do I change the name and description of a wizard page from within InitializeWizard?)

如何使用 Inno Setup 根據註冊表項選擇在文件夾中安裝插件/文件? (How do I use Inno Setup to optionally install a plugin/file in a folder based on a registry entry?)

Inno Setup - 透明閃屏 (Inno Setup - Transparent Splash Screen)

Instal versi Firebird yang benar (32bit atau 64bit) dengan Inno Setup (Install correct version of Firebird (32bit or 64bit) with Inno Setup)

Inno Setup - 防止提取文件將進度條設置為 100% (Inno Setup - Prevent extraction of files from setting progress bar to 100%)

在安裝期間將 .INI 文件從 UTF-8 編碼轉換為 ANSI (To convert a .INI file from UTF-8 encoding to ANSI during installation)

將 Inno Setup 安裝程序包裝在 MSI 中以便通過 AD 進行分發是否可行/明智? (Is it feasible/sensible to wrap an Inno Setup installer inside an MSI for easier distribution via AD?)

在沒有 ClickOnce 的情況下從安裝程序下載並安裝 .net framework 4.0? (Download and install .net framework 4.0 from installer without ClickOnce?)

如何在 Inno Setup 中設置“典型”和“自定義”安裝選項? (How to make a "Typical" and "Custom" installation option in Inno Setup?)

Inno Setup Windows DLL 函數調用,帶有指向結構的指針 (Inno Setup Windows DLL function call with pointer to structure)

更改 WizardForm.TasksList 偏移量 (Change WizardForm.TasksList offset)

如何在 Inno Setup 中修改錯誤信息? (How to modify error message in Inno Setup?)







留言討論