;INNO 讀取可變註冊表路徑的問題app
;問題:
;我想自動爲 FireFox 安裝上 Real 的 Mozilla 插件~可是它的路徑存放在"HKEY_CURRENT_USER\Software\Mozilla\Mozilla Firefox\1.5 (zh-CN)\Main" Install Directory 下~中間的 1.5 (zh-CN) 會隨版本和語言不一樣而變化怎麼樣才能忽略中間的 1.5 (Zh-cn) 直接讀取下級子鍵 Main 下的內容呢?<!--QuoteEnd--><!--QuoteEEnd-->插件
;答案:
;請參考如下示例。code
[Setup]
AppName=個人程序
AppVerName=個人程序 版本 1.5
DefaultDirName={pf}\個人程序
DefaultGroupName=個人程序ip
[Files]
;Source: MyProg.exe; DestDir: {app}
;Source: MyProg.hlp; DestDir: {code:getAFolder}
;Source: Readme.txt; DestDir: {app}get
[Languages]
Name: en; MessagesFile: "compiler:Default.isl"
Name: nl; MessagesFile: "compiler:Languages\Dutch.isl"
Name: de; MessagesFile: "compiler:Languages\German.isl"string
[CustomMessages]
en.MyDescription=My description
en.MyAppName=My Program
en.MyAppVerName=My Program %1
en.ProgramFailed=本程序的%1版本已經安裝,請卸載後再安裝本程序. 安裝程序將關閉.it
nl.MyDescription=Mijn omschrijving
nl.MyAppName=Mijn programma
nl.MyAppVerName=Mijn programma %1
nl.ProgramFailed=本程序的%1版本已經安裝,請卸載後再安裝本程序. 安裝程序將關閉.io
de.MyAppName=Meine Anwendung
de.MyDescription=Meine Beschreibung
de.MyAppVerName=Meine Anwendung %1
de.ProgramFailed=本程序的%1版本已經安裝,請卸載後再安裝本程序. 安裝程序將關閉.function
[Code]
// Code added by gnatix
var
FirefoxInstallDir: string;程序
function getAFolder(default: String): String;
begin
if FirefoxInstallDir <> '' then // if found
Result := FirefoxInstallDir
else
Result := ExpandConstant('{app}'); // if not found
end;
function GetInstalledVersion(): String;
var
InstalledVersion: String;
begin
InstalledVersion :='';
RegQueryStringValue(HKLM, 'Software\BlueStacks', 'Version', InstalledVersion);
Result := InstalledVersion;
end;
function InitializeSetup(): Boolean;
var
PrevVer: String;
S: String;
begin
PrevVer := GetInstalledVersion();
result := true;
if length(PrevVer) > 0 then begin
S := CustomMessage('ProgramFailed');
StringChange(S, '%1', PrevVer);
//若是發現程序已經安裝過了
MsgBox (S, mbError, MB_OK);
result := false;
end;
end;
//procedure InitializeWizard(); //;var ;//;SubKeyNames: TArrayOfString;//i: Integer;//begin//FirefoxInstallDir:= '';//if RegGetSubkeyNames(HKEY_CURRENT_USER, 'Software\Mozilla\Firefox', SubKeyNames) then//for i := 0 to GetArrayLength(SubKeyNames)-1 do //RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Mozilla\Firefox\' + SubKeyNames[i] +'\Main', 'Install Directory', FirefoxInstallDir);//end;