Based on the answers of @Slava Ivanov and @MB. , code for Inno Setup
const AppPathsKey = 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths'; const SCS_32BIT_BINARY = 0; SCS_64BIT_BINARY = 6; function GetBinaryType(ApplicationName: string; var BinaryType: Integer): Boolean; external 'GetBinaryTypeW@kernel32.dll stdcall'; function GetAppVersionAndBinaryType( ProgramFileName: string; var Version: string; var BinaryType: Integer): Boolean; var ProgramPath: string; begin Result := RegQueryStringValue(HKLM, AppPathsKey + '\' + ProgramFileName, '', ProgramPath); if not Result then begin Log(Format('Cannot find a path to "%s"', [ProgramFileName])); end else begin Log(Format('Path to "%s" is "%s"', [ProgramFileName, ProgramPath])); Result := GetVersionNumbersString(ProgramPath, Version); if not Result then begin Log(Format('Cannot retrieve a version of "%s"', [ProgramFileName])); end else begin Log(Format('Version of "%s" is "%s"', [ProgramFileName, Version])); Result := GetBinaryType(ProgramPath, BinaryType); if not Result then begin Log(Format('Cannot retrieve a binary type of "%s"', [ProgramFileName])); end else begin Log(Format('Binary type of "%s" is "%d"', [ProgramFileName, BinaryType])); end; end; end; end;
Code for Unicode version of Inno Setup .
Martin Prikryl Nov 22 '17 at 20:49 2017-11-22 20:49
source share