1

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; ValueData: "MeetingScheduleAssistant.MeetingWorkBook"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.MeetingWorkBook"; ValueType: string; ValueData: "Meeting Workbook"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.MeetingWorkBook\Shell\Open\Command"; ValueType: string; ValueData: """{app}\MeetSchedAssist.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.MeetingWorkBook\DefaultIcon"; ValueType: string; ValueData: "{app}\MeetSchedAssist.exe,0"; Flags: uninsdeletevalue

Root: HKCR; SubKey: ".srr"; ValueType: string; ValueData: "MeetingScheduleAssistant.SoundRotaReport"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.SoundRotaReport"; ValueType: string; ValueData: "Sound Rota Report"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.SoundRotaReport\Shell\Open\Command"; ValueType: string; ValueData: """{app}\MeetSchedAssist.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.SoundRotaReport\DefaultIcon"; ValueType: string; ValueData: "{app},1"; Flags: uninsdeletevalue

My installer ships with the above 32bit exe but it also has a _64x executable. What is the right way to register from both environments? Do I just duplicate the code, like this:

; Register File Types 32 bit
Root: HKCR; SubKey: ".mwb"; ValueType: string; ValueData: "MeetingScheduleAssistant.MeetingWorkBook32"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.MeetingWorkBook32"; ValueType: string; ValueData: "Meeting Workbook"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.MeetingWorkBook32\Shell\Open\Command"; ValueType: string; ValueData: """{app}\MeetSchedAssist.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.MeetingWorkBook32\DefaultIcon"; ValueType: string; ValueData: "{app}\MeetSchedAssist.exe,0"; Flags: uninsdeletevalue

Root: HKCR; SubKey: ".srr"; ValueType: string; ValueData: "MeetingScheduleAssistant.SoundRotaReport32"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.SoundRotaReport32"; ValueType: string; ValueData: "Sound Rota Report"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.SoundRotaReport32\Shell\Open\Command"; ValueType: string; ValueData: """{app}\MeetSchedAssist.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.SoundRotaReport32\DefaultIcon"; ValueType: string; ValueData: "{app},0"; Flags: uninsdeletevalue

; Register File Types 64 bit
Root: HKCR; SubKey: ".mwb"; ValueType: string; ValueData: "MeetingScheduleAssistant.MeetingWorkBook64"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.MeetingWorkBook64"; ValueType: string; ValueData: "Meeting Workbook"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.MeetingWorkBook64\Shell\Open\Command"; ValueType: string; ValueData: """{app}\MeetSchedAssist_x64.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.MeetingWorkBook64\DefaultIcon"; ValueType: string; ValueData: "{app}\MeetSchedAssist_x64.exe,0"; Flags: uninsdeletevalue

Root: HKCR; SubKey: ".srr"; ValueType: string; ValueData: "MeetingScheduleAssistant.SoundRotaReport64"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.SoundRotaReport64"; ValueType: string; ValueData: "Sound Rota Report"; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetingScheduleAssistant.SoundRotaReport64\Shell\Open\Command"; ValueType: string; ValueData: """{app}\MeetSchedAssist_x64.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.SoundRotaReport64\DefaultIcon"; ValueType: string; ValueData: "{app}\MeetSchedAssist_x64.exe,0"; Flags: uninsdeletevalue

I can't see how this would work because the user double-clicks the file so how does it know which of the exe files to use?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • You should install and register only one executable, 32-bit or 64-bit – According to the bitness of the system (and user preference). – Martin Prikryl May 07 '20 at 20:39
  • @MartinPrikryl I have for many years now shipped both exe files since they use the same underlying data files. So users have become accustomed to both exe files being installed. What script would I need to offer the user to choose which executable to associate with the file types? That would be a starting point. Maybe I could then add a menu item in my application to change the associations to the active exe. Could you provide a sample for the inno side of things please? – Andrew Truckle May 07 '20 at 20:43
  • @MartinPrikryl The other reason I offer both by default (if they are x64) is because of the reliance on MDB/ACCDB database drivers and in my case MDB works with 32bit and ACCDB works with 64bit. So depending on what mood there in they go for one or the other at any time. – Andrew Truckle May 07 '20 at 20:52

1 Answers1

2

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.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Thanks. The minimum supported version for my software is Windows 7. So your first approach sounds ideal! Let me look at that. – Andrew Truckle May 07 '20 at 22:28
  • 1
    You will have to repeat the whole registration for both versions – with unique IDs both for the software (`TruckleSoft32`, `TruckleSoft64`) and the associations (`MeetingScheduleAssistant.MeetingWorkBook32`, `MeetingScheduleAssistant.MeetingWorkBook64` ...). You can use preprocessor to avoid having to repeat everything. – Martin Prikryl May 08 '20 at 04:55