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

查看:57
本文介绍了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.MeetingWorkBookShellOpenCommand"; ValueType: string; ValueData: """{app}MeetSchedAssist.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.MeetingWorkBookDefaultIcon"; 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.SoundRotaReportShellOpenCommand"; ValueType: string; ValueData: """{app}MeetSchedAssist.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.SoundRotaReportDefaultIcon"; 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.MeetingWorkBook32ShellOpenCommand"; ValueType: string; ValueData: """{app}MeetSchedAssist.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.MeetingWorkBook32DefaultIcon"; 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.SoundRotaReport32ShellOpenCommand"; ValueType: string; ValueData: """{app}MeetSchedAssist.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.SoundRotaReport32DefaultIcon"; 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.MeetingWorkBook64ShellOpenCommand"; ValueType: string; ValueData: """{app}MeetSchedAssist_x64.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.MeetingWorkBook64DefaultIcon"; 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.SoundRotaReport64ShellOpenCommand"; ValueType: string; ValueData: """{app}MeetSchedAssist_x64.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "MeetingScheduleAssistant.SoundRotaReport64DefaultIcon"; 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 Setup:扩展 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.MeetingWorkBook32ShellOpenCommand"; 
    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;

要根据用户偏好选择可执行文件,您可以使用[Tasks]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.MWBShellOpenCommand"; ValueType: string; ValueData: """{app}{code:GetExecutableToRegister}"" ""%1"""; Flags: uninsdeletekey
Root: HKCR; SubKey: "MeetSchedAssist.SRRShellOpenCommand"; 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天全站免登陆