Search code examples
excelinstallationregistryinno-setup

call RegQueryDWordValue to get office Excel Version using inno Setup installer


How do I get installed Version of MS office Excel from registry using inno Script? i tried bellow code,it gives 'Key not found' but it exist

   function InitializeSetup(): Boolean;
 var
  CurVer: Cardinal;
  key: string;

if RegQueryDWordValue(HKCR, 'Excel.Application\CurVer\','Default', CurVer) then
  begin
    // Successfully read the value
      MsgBox('Excel Version: ' + IntTOStr(CurVer),mbInformation, MB_OK);
    end else begin
      MsgBox('Key not found',mbInformation, MB_OK);
  end;

end;

Solution

  • changed RegQueryDWordValue to RegQueryStringValue

    function InitializeSetup(): Boolean;
     var
      CurVer: Cardinal;
      key: string;
    
    begin
    
    
         //if RegQueryDWordValue(HKCR, 'Excel.Application\\CurVer\\','', CurVer) then
         if RegQueryStringValue(HKCR, 'Excel.Application\CurVer\','', key) then
      begin
        // Successfully read the value
          MsgBox('Excel Version: ' + key,mbInformation, MB_OK);
        end else begin
          MsgBox('Excel Not installed',mbInformation, MB_OK);
      end;
    
    end;