且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

升级时根据活动文件类型关联设置任务值

更新时间:2023-02-08 18:49:05

根据你的上一个问题,我知道您的注册看起来像:

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;