Я создаю установщик для Microsoft Office, специально для версий 2007 - 2013. Он просто копирует некоторые файлы в два каталога Office. Моя Windows 64-битная, но я хочу создать установщик для архитектур x64 и x86.
Поэтому я написал следующий код, который пытается взять из реестра Windows путь установки Office. И для каждой версии Office (2007–2013) он берет путь установки и добавляет остальную часть пути, который мне нужен. Вот результат, которого я хочу.
[Code]
function GetHKLM() : Integer;
begin
if IsWin64 then
begin
Result := HKLM64;
end
else
begin
Result := HKEY_LOCAL_MACHINE;
end;
end;
function officeInstallDir(Param: string): string;
// This function takes the type of desired directory,
// verify the version of Office and returns the correct
// directory for style or bibform.
var
styleFolder, bibformFolder : string;
begin
// It verifies the Office version through the registry's subkey and it sets the correct Office's path.
if RegKeyExists(GetHKLM(), '\SOFTWARE\Microsoft\Office\15.0') then begin
styleFolder := '{userappdata}\Roaming\Microsoft\Bibliography\Style';
RegQueryStringValue(GetHKLM(), '\SOFTWARE\Microsoft\Office\15.0\Common', 'InstallRoot', bibformFolder);
bibformFolder := bibformFolder + '\1046\Bibliography';
end else begin
if RegKeyExists(GetHKLM(), '\SOFTWARE\Microsoft\Office\14.0') then begin
RegQueryStringValue(GetHKLM(), '\SOFTWARE\Microsoft\Office\14.0\Common', 'InstallRoot', styleFolder);
styleFolder := styleFolder + 'Bibliography\Style';
bibformFolder := styleFolder + '1046\Bibliography';
end else begin
if RegKeyExists(GetHKLM(), '\SOFTWARE\Microsoft\Office\12.0') then begin
RegQueryStringValue(GetHKLM(), '\SOFTWARE\Microsoft\Office\12.0\Common', 'InstallRoot', styleFolder);
styleFolder := styleFolder + 'Bibliography\Style';
bibformFolder := styleFolder + '1046\Bibliography';
end
end;
end;
// Set the result according Param passed (the first or second type of path).
if Param = 'style' then begin
result := styleFolder;
end else begin
result := bibformFolder;
end;
end;
С одним из путей я попытался установить путь установки файла (DestDir) в Inno Setup следующим образом:
[Files]
Source: "E:\Google Drive\Informática\Bibword\Bibword Estilos\*"; DestDir: "{code:officeInstallDir|style}"; Flags: ignoreversion
Source: "E:\Google Drive\Informática\Bibword\Bibword file\BIBFORM.xml"; DestDir: "{code:officeInstallDir|bibform}"; Flags: ignoreversion
Но если я передаю параметры style или bibform, функция officeInstallDir должна помочь мне установить правильный путь для каждой строки. Но RegKeyExists или RegQueryStringValue не находит подразделы реестра. Я даже пытался использовать функцию GetHKLM() из-за проблемы с 64-битным узлом, но безрезультатно.
Кто-нибудь поможет мне?