Inno Setup-同时注册32位和64位 [英] Inno Setup - Register for both 32 bit and 64 bit

查看:166
本文介绍了Inno Setup-同时注册32位和64位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅当我正在注册文件类型时,此问题才会出现:

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

我的安装程序附带上述32位exe,但它也具有 _64x 可执行文件。从这两种环境进行注册的正确方法是什么?我是否只复制代码,像这样:

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

我看不到它如何工作,因为用户双击了文件如何知道要使用哪个exe文件?

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?

推荐答案

如果使用现代方法注册关联,则可以注册多个应用程序(因此您的应用程序是32位和64位版本)。然后,系统将在第一次用户尝试打开相应的文件类型时提示用户选择要使用的应用程序。另外,用户将能够在控制面板(或Windows 10设置应用程序)中更改决定。

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).

请参见 Inno设置:扩展Windows默认应用程序列表

您将不得不重复两个版本的整个注册过程(具有唯一性)软件和关联的ID)。您可以使用预处理器来避免重复代码。

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.

这至少需要Windows Vista。

This needs Windows Vista at least.

如果您想坚持使用注册应用程序的方式(或者如果您需要支持Windows的较早版本),则只需注册一个版本的应用程序。

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.

您可以使用脚本常量 > [Registry] 部分:

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
...

根据以下内容选择可执行文件要使用系统,请使用 IsWin64 函数

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;

要根据用户喜好选择可执行文件,可以使用 [任务] WizardIsTaskSelected 函数

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;

(未测试)

由OP更新:

我设法开始工作此代码:

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

上面使用了 Tasks 。尽管我对任务有单独的问题,并且由于某种原因桌面没有刷新。但是以上工作。使用新系统失败。

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.

这篇关于Inno Setup-同时注册32位和64位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆