I'm creating an installer for Microsoft Office, specifically for 2007 - 2013 versions. It just copy some files inside two Office's directories. My Windows is 64bit but I want to create a installer for both x64 and x86 architectures.
So I wrote the following code that tries to take from the Windows registry the Office's installation path. And, for each version of Office (2007 - 2013), it takes the installation's path and append the rest of the path I need. That's the result I want.
[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;
With one of the paths, I tried to set the file's installation path (DestDir) in Inno Setup like this:
[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
But if I pass the parameters style or bibform, the function officeInstallDir should help me set the correct path for each line. But RegKeyExists or RegQueryStringValue doesn't find the registry's subkeys. I even tried using the GetHKLM() function because the 64bit node problem but no go.
Would anyone help me?