5
votes

i am currently trying to create a custom script for installing a program. i need to check if the runtime engine of crystal reports 13 is installed, if not then installed. this is what i am trying to do:

  //check crystalReports
  if (not RegKeyExists(HKLM, 'Software\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports')) then
  begin
      crystalReportsNeeded := true;
      if (not IsAdminLoggedOn()) then begin
          MsgBox('GasSoft needs the Crystal Reports to be installed by an Administrator', mbInformation, MB_OK);
          Result := false;
      end 
      else 
      begin
          memoDependenciesNeeded := memoDependenciesNeeded + '     Crystal Reports' #13;
          SetIniString('install', 'dotnetRedist', dotnetRedistPath,  ExpandConstant('{tmp}\dep.ini'));
     end;
  end else
  begin 
       MsgBox('installed cr', mbInformation, MB_OK);
  end;

so this is updating a var caleed crystallreportsneeded to true or false. this variable will be use on the check function of the file. i have check on the control panel that the runtime engine is installed, but every time i run the setup it tries to installed the file. What am i missing., is the regkey correct?

After a bit of search i found out that some people instead of searching the folder goes to uninstal folder in HKLM->Windowns->CurrentVersion->Unistall.. in my case there is a register of the sap component with a product code but this does create a problem, if by any mean i update the version of the sap crystal reports through the web, and then try to run the setup script it creates a problem where the current version installed is newer than the one i am currently trying to install...

14/10/2014 - Update... So i still cant check if the program is installed or not, i have also tried doing this

sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{{1D8E6291-B0D5-35EC-8441-6616F567A0F7}}'); //Your App GUID/ID
sUnInstallString := '';
if RegQueryStringValue(HKLM, sUnInstPath, 'InstallDate', sUnInstallString) then
MsgBox('Exists... ' , mbInformation, MB_OK);

this 1D8E6291-B0D5-35EC-8441-6616F567A0F7 refers to app id in this case vcc+... and i also tried this

RegQueryDWordValue(HKLM, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{{1D8E6291-B0D5-35EC-8441-6616F567A0F7}}', 'Version', version);

it doesnt show the message,, for the moment there are 2 options, one always install, and two check if file exists with FileExists..so any help is appreciated..

Update - 15/10/2014 So i think i have found a workaround, i dont think that this a solution because i cant explain some of the things that are happening.. This workaround is only in the case you are using Crystal reports and still needs to be tested in a 32 bits machine,but i almost certain that it will also work. for the moment i am testing on 64bits machine with win 8.1,and i will test the scripts in a 32bits also.

So i need to separate the scripts one for x32 and other for x64. the diference was in the [setup] parameters, if setup is for 64 bits it needs these 2 lines:

ArchitecturesInstallIn64BitMode=x64
ArchitecturesAllowed=x64

these are the description:

ArchitecturesAllowed=x64 specifies that Setup cannot run on anything but x64. ArchitecturesInstallIn64BitMode=x64" requests that the install be done in "64-bit mode" on x64, meaning it should use the native 64-bit Program Files directory and the 64-bit view of the registry.

so i am currently stating that the script can only work on 64bits, and that the folder system is 64bits..

after adding these 2 lines the code for finding the key executes with success. the code for trying to find if the key exists is below..

sKey:=ExpandConstant('SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports');
MsgBox('Before if'  , mbInformation, MB_OK); //trying to test if is reaching this statement..
if( RegKeyExists(HKLM, sUnInstPath)) then begin
   MsgBox('key found'  , mbInformation, MB_OK);

this only happens if you need to install the crystal reports runtime engine 64bits. on my script i am checking for the existence of sql server are installed, if not exists then install.

if you have installed crruntime engine 32bits in a 64bits machine then you dont need to add the lines.. the path of the key is now SOFTWARE\Wow6432Node\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports i dont know if it is possible to add an if condition on the [Setup] that state that the 2lines of code are added if i am running the setup in a 64 bits machine..

if there are new updates to the situation i will update the post... Thanks in advance..

1
If you'll be running on 64-bit Windows (IsWin64 function can tell you that) and your setup will run in 32-bit mode (if you omit the ArchitecturesInstallIn64BitMode directive), you can access the 64-bit registry view by using HKLM64 root key. There are two views on registry, 32-bit and 64-bit one. Because Inno Setup is 32-bit application, it maps by default to 32-bit registry view and as you describe, the key you are looking for is stored in 64-bit registry view (that's what you can see under non Wow node if you run 64-bit regedit, which is the default one on 64-bit Windows).TLama
I think that on 64bit systems you should check both views for that key presence since on 64-bit system you can install 32-bit or 64-bit Crystal Reports, don't you ? And I believe that 32-bit CR will write to 32-bit reg. view and 64-bit to 64-bit.TLama
It depends on which regedit you are looking at. There are two regedits on your system. One is 32-bit and the second one 64-bit. By default is opened the 64-bit one which shows 64-bit view as a normal tree and the 32-bit view under Wow6432Node. The 32-bit one does it vice versa. You are not accessing the Wow6432Node node directly. You are having the redirector for that. Inno Setup allows you to access both views. If you are running it in 32-bit mode (without ArchitecturesInstallIn64BitMode directive), the HKLM (or HKLM32) maps to 32-bit registry view whilst HKLM64 to 64-bit.TLama
You're welcome! If you would like to learn more about registry redirector, you can follow this topic. It sounds complicated, but in short it's easy. 32-bit apps (whatever they are) are by default accessing 32-bit registry view, 64-bit apps. 64-bit view. What you are (by default) opening in 64-bit Windows is 64-bit regedit which shows 32-bit view under the Wow6432Node node. And by default Inno Setup runs in so called 32-bit mode which maps root keys (like HKLM) to 32-bit registry view.TLama
It is a 32-bit application and as such is by default (unless you use that 64-bit mode) accessing 32-bit view. I would blame regedit which doesn't show bitness views in some useful view. People usually open (default) 64-bit regedit and see a certain key in the non Wow6432Node (64-bit view). Then they try to open such key under the default view in their 32-bit application wondering "where's my key ?". And yes, when you use HKLM64, you are always accessing 64-bit view (that's why you must check if you are on 64-bit system, because there is no such view on 32-bit systems).TLama

1 Answers

2
votes

So thanks to user TLama, that explained how inno setup works on a 64bits machine.. here is the code for checking if crystal reports runtime engine 13 is installed:

[Code]
const
    CrystalReportsKey = 'SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 
4.0\Crystal Reports';
var
    crNeeded:boolean;
    memoDependenciesNeeded: string;
function InitializeSetup(): Boolean;
begin
    if (IsWin64 and (not RegKeyExists(HKLM64, CrystalReportsKey) or not RegKeyExists(HKLM32,CrystalReportsKey))) or
(not IsWin64 and not RegKeyExists(HKLM, CrystalReportsKey))) then begin
        crNeeded:=true;
        memoDependenciesNeeded := memoDependenciesNeeded + '    Crystal Reports 13' #13;
         end;
end;

so i am checking if i am running on a 32 bits windows or a 64 bits windows.

if running on a 64bits windows i am checking the existence of a regkey on the HKLM 64bits view, if the key exists the var crNeeded maintains the initially value of false, if not then we need to check the 32 bits view of regkeys just in case if Crystal Reports installed was a 32 bits executable. if still no regkey then we set the variable crNeeded to true stating that we need to install crystal reports.

i changed the if clause from ProcessorArchitecture=paX64 to IsWin64 , because the ProcessorArchitecture is checking if the processor is 64bits or 32 bits, and this can cause an exception if there is a 32bits windows on a 64bits machine.

The variable crNeeded will be used on a check function of the file, i mean it will only install if we this variable is true. Once again thanks again to user TLama for all the help... Thanks..