Inno Setup - Register for both 32 bit and 64 bit

前端 未结 1 851
面向向阳花
面向向阳花 2021-01-16 11:33

This issue has only raised itself now that I am registering my file types:

; Register File Types 32 bit
Root: HKCR; SubKey: \".mwb\"; ValueType: string; Valu         


        
相关标签:
1条回答
  • 2021-01-16 12:24

    If you use the modern method for registering associations, you can register multiple applications (so both 32-bit and 64-bit versions of your application). System will then prompt user to select which application to use, the first time user tries to open the respective file type. Also, the user will be able to change the decision in the Control Panel (or Windows 10 Settings app).

    See Inno Setup: Extending Windows default apps list

    You will have to repeat the whole registration for both versions (with unique IDs both for the software and the associations). You can use preprocessor to avoid having to repeat the code.

    This needs Windows Vista at least.


    If you want to stick with your way to register the application (or if you need to support older versions of Windows), you will need to register one version of your application only. Either according to the bitness of the system or according to user preference.

    You can use a scripted constant in the [Registry] section:

    [Registry]
    ...
    Root: HKCR; SubKey: "MeetingScheduleAssistant.MeetingWorkBook32\Shell\Open\Command"; \
        ValueType: string; ValueData: """{app}\{code:GetExecutableToRegister}"" ""%1"""; \
        Flags: uninsdeletekey
    ...
    

    To select the executable according to the bitness of the system, use IsWin64 function:

    [Code]
    function GetExecutableToRegister(Param: string): string;
    begin
      if IsWin64 then
        Result := 'MeetSchedAssist_x64.exe'
      else
        Result := 'MeetSchedAssist.exe';
    end;
    

    To select the executable according to user preference, you can use [Tasks] and WizardIsTaskSelected function:

    [Tasks]
    Name: register32; Description: "Register 32-bit executable"; Check: IsWin64; \
        flags: unchecked;
    Name: register64; Description: "Register 64-bit executable"; Check: IsWin64 
    
    [Code]
    function GetExecutableToRegister(Param: string): string;
    begin
      if IsWin64 and WizardIsTaskSelected('register64') then
        Result := 'MeetSchedAssist_x64.exe'
      else
        Result := 'MeetSchedAssist.exe';
    end;
    

    (untested)


    Update by OP:
    This code I managed to get to work:

    ; Register File Types
    Root: HKCR; SubKey: ".mwb"; ValueType: string; ValueData: "MeetSchedAssist.MWB"; Flags: uninsdeletekey
    Root: HKCR; SubKey: ".srr"; ValueType: string; ValueData: "MeetSchedAssist.SRR"; Flags: uninsdeletekey
    Root: HKCR; Subkey: "MeetSchedAssist.MWB"; ValueType: string; ValueData: "Meeting Workbook Schedule"; Flags: uninsdeletekey
    Root: HKCR; Subkey: "MeetSchedAssist.SRR"; ValueType: string; ValueData: "Sound Rota Report"; Flags: uninsdeletekey
    Root: HKCR; SubKey: "MeetSchedAssist.MWB\Shell\Open\Command"; ValueType: string; ValueData: """{app}\{code:GetExecutableToRegister}"" ""%1"""; Flags: uninsdeletekey
    Root: HKCR; SubKey: "MeetSchedAssist.SRR\Shell\Open\Command"; ValueType: string; ValueData: """{app}\{code:GetExecutableToRegister}"" ""%1"""; Flags: uninsdeletekey
    

    The above uses the Tasks. Although I have a separate issue about the tasks, and, for some reason the "Desktop" did not refresh. But the above works. Using the new system fails.

    0 讨论(0)
提交回复
热议问题