升级时根据活动文件类型关联设置任务值 [英] Setting task value based on active file type associations when upgrading
问题描述
我的安装程序中包含以下任务:
I have the following tasks as part of my installer:
[Tasks]
Name: register32; Description: "Meeting Schedule Assistant (32 bit)"; \
GroupDescription: "{cm:FileAssociations}"; flags: unchecked exclusive;
Name: register64; Description: "Meeting Schedule Assistant (64 bit)"; \
GroupDescription: "{cm:FileAssociations}"; Check: IsWin64; Flags: exclusive;
根据设计,Inno Setup已设置 UsePreviousTasks
到是
。但是,我的软件同时安装了两个位版本,用户随后可以通过应用程序设置覆盖安装程序的默认设置。
By design, Inno Setup has UsePreviousTasks
set to Yes
. However, my software installs both bit editions and the user may subsequently override the installer default via application settings.
因此,当我的安装程序进行升级时,它可以确定哪个位版本
Therefore, when my installer is upgrading, can it determine which bit edition is actively registered and leave it set as that value?
推荐答案
基于您的上一个问题,我知道您的注册看起来像这样:
Based on your previous question, I know that your registrations look like:
[HKEY_CLASSES_ROOT\MeetSchedAssist.MWB\Shell\Open\Command]
@="\"C:\\Program Files (x86)\MeetSchedAssist\MeetSchedAssist.exe\" \"%1\""
[HKEY_CLASSES_ROOT\MeetSchedAssist.MWB\Shell\Open\Command]
@="\"C:\\Program Files\MeetSchedAssist\MeetSchedAssist_x64.exe\" \"%1\""
因此,您可以查询已注册的命令并在命令中查找相应的可执行文件名称。
So you can query the registered command and look for a respective executable name in the command.
procedure InitDefaultFileAssociationsTaskValue;
var
SubKeyName, Command: string;
begin
SubKeyName := 'MeetSchedAssist.MWB\Shell\Open\Command';
if not RegQueryStringValue(HKCR, SubKeyName, '', Command) then
begin
Log('MWB registration not found');
end
else
begin
Log(Format('Command registered for MWB is [%s]', [Command]));
Command := Lowercase(Command);
if Pos('meetschedassist_x64.exe', Command) > 0 then
begin
Log('Detected 64-bit registration');
WizardSelectTasks('register64');
end
else
if Pos('meetschedassist.exe', Command) > 0 then
begin
Log('Detected 32-bit registration');
WizardSelectTasks('register32');
end
else
begin
Log('Registration not recognised');
end;
end;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectTasks then
begin
{ Only now is the task list initialized. }
InitDefaultFileAssociationsTaskValue;
end;
end;
您可能需要修改它以更改任务仅在用户首次进入任务页面时进行选择。
You may want to modify this to change the task selection only the first time the user enters the tasks page.
var
SelectTasksVisited: Boolean;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectTasks then
begin
{ Only now is the task list initialized. }
if not SelectTasksVisited then
begin
InitDefaultFileAssociationsTaskValue;
SelectTasksVisited := True;
end;
end;
end;
这篇关于升级时根据活动文件类型关联设置任务值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!