升级时根据活动文件类型关联设置任务值 [英] 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
设置为 Yes
.但是,我的软件安装了两个位版本,用户随后可能会通过应用程序设置覆盖安装程序的默认设置.
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_ROOTMeetSchedAssist.MWBShellOpenCommand]
@=""C:\Program Files (x86)MeetSchedAssistMeetSchedAssist.exe" "%1""
[HKEY_CLASSES_ROOTMeetSchedAssist.MWBShellOpenCommand]
@=""C:\Program FilesMeetSchedAssistMeetSchedAssist_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.MWBShellOpenCommand';
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屋!