Inno setup 检测CorelDraw注册表

1.检测注册表中CorelDraw

begin 
  if IsWin64 then
  begin
    RootKey := HKLM64;
  end
  else
  begin
    RootKey := HKLM32;
  end;
  Flag:= False;
   if RegGetSubkeyNames(HKCU, 'SOFTWARE\Corel\CorelDRAW', Names) then
  begin
    CheckTreePage := CreateCustomPage(wpSelectTasks, '请选择要安装的版本', '');
    CheckTreePage.OnNextButtonClick := @NextStepButtonClick; 
    Labels:= TLabel.Create(CheckTreePage);
    Labels.Parent:= CheckTreePage.Surface
    CheckListBox := TNewCheckListBox.Create(WizardForm); 
    CheckListBox.Parent := CheckTreePage.Surface; 
    CheckListBox.Top := WizardForm.SelectTasksLabel.Top; 
    CheckListBox.Width := WizardForm.TasksList.Width; 
    CheckListBox.Left := WizardForm.TasksList.Left; 
    CheckListBox.Height := 
    WizardForm.TasksList.Top + WizardForm.TasksList.Height - CheckListBox.Top; 
    CheckListBox.WantTabs := True;
    CheckListBox.BorderStyle := bsNone; 
    CheckListBox.MinItemHeight := WizardForm.TasksList.MinItemHeight
    PathList := TStringList.Create;
    
    CheckListBox.AddCheckBox(
    '请选择要安装的版本', '', 0, False, True, False, False, nil); 
    for I := 0 to GetArrayLength(Names)-1 do
    begin;
      RegQueryStringValue(RootKey, 'SOFTWARE\WOW6432Node\Corel\CorelDRAW\' + Names[I], 'ConfigDir', PathString);
      if Trim(PathString)  = '' Then
      begin
        RegQueryStringValue(RootKey, 'SOFTWARE\Corel\CorelDRAW\' + Names[I], 'ConfigDir', PathString);
      end;
      if Pos('Config', PathString) > 0 then
      begin
        tempPath := Copy(PathString, 1, Pos('Config', PathString) - 1);
        PathList.Add(tempPath);
        begin
          if Pos('14.0',Names[I]) > 0 then
          begin
             CheckListBox.AddCheckBox(
            'CorelDRAW X4', '', 1, False, True, False, True, nil);
            X4Path:= PathString;
          end else if Pos('17.0', Names[I]) > 0 then
          begin
            CheckListBox.AddCheckBox(
            'CorelDRAW X7', '', 1, False, True, False, True, nil);
          end else if Pos('18.0', Names[I]) > 0 then
          begin
            CheckListBox.AddCheckBox(
            'CorelDRAW X8', '', 1, False, True, False, True, nil);
          end else if Pos('19.0', Names[I]) > 0 then
          begin
            CheckListBox.AddCheckBox(
            'CorelDRAW 2017', '', 1, False, True, False, True, nil);
          end else if Pos('20.0', Names[I]) > 0 then
          begin
            CheckListBox.AddCheckBox(
            'CorelDRAW 2018', '', 1, False, True, False, True, nil);
          end else if Pos('21.0', Names[I]) > 0 then
          begin
            CheckListBox.AddCheckBox(
            'CorelDRAW 2019', '', 1, False, True, False, True, nil);
          end else if Pos('22.0', Names[I]) > 0 then
          begin
            CheckListBox.AddCheckBox(
            'CorelDRAW 2020', '', 1, False, True, False, True, nil);
          end else if Pos('23.0', Names[I]) > 0 then
          begin
            CheckListBox.AddCheckBox(
            'CorelDRAW 2021', '', 1, False, True, False, True, nil);
          end else if Pos('24.0', Names[I]) >0 then
          begin
            CheckListBox.AddCheckBox(
            'CorelDRAW 2022', '', 1, False, True, False, True, nil);  
          end;
        end;
      end;
    end;
    CheckListBox.OnClickCheck:= @ClickEvent;
  end else
  begin
    MsgBox('CorelDRAW没有安装', mbInformation, MB_OK);
    ExitProcess(-1);
  end; 
end;

2.找到CorelDraw安装位置:

我找的是ConfigDir的位置,也可以找programsdir位置,但是X4版本的注册表中没有programsdir

function CheckX17DirExists(): Boolean;
var
  s: Integer;
  TStr: String;
  RootKey: Integer;
begin
if IsWin64 then
  begin
    RootKey := HKLM64;
  end
  else
  begin
    RootKey := HKLM32;
  end;
  for s:= 0 to SelectPath.Count-1 do
  begin
    if Pos('19.0', SelectPath[s]) > 0 then
    begin
      RegQueryStringValue(RootKey, 'SOFTWARE\WOW6432Node\Corel\CorelDRAW\' + SelectPath[s], 'ConfigDir', TStr);
      if Trim( TStr) ='' then
      begin
        RegQueryStringValue(RootKey, 'SOFTWARE\Corel\CorelDRAW\'+ SelectPath[s], 'ConfigDir', TStr);
      end;
    end;
  end;
  X17Path:= TStr;
 //  MsgBox(X17Path, mbInformation, MB_OK);
  if InstallFlag = False then
  begin
    InstallFlag := DirExists(TStr);
  end;
  Result:= DirExists(X17Path);
end;

X7、X8、2017、2018的Config是大写,2019及以上是小写config

function ReadPathX7(x: String): String;
var
  tempPath: String;
begin
  tempPath := Copy(X7Path, 1, Pos('Config', X7Path) - 1);
  Result:=tempPath;
end;

[File]段安装的位置:xxx为需要放入CorelDraw的文件

Source: "C:\Users\Administrator\Desktop\xxx"; DestDir: "{code:ReadPathX4}\Draw\Plugins"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: CheckX4DirExists
Source: "C:\Users\Administrator\Desktop\Gms\xxx"; DestDir: "{code:ReadPathX7}\Draw\Plugins64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: CheckX7DirExists
Source: "C:\Users\Administrator\Desktop\xxx"; DestDir: "{code:ReadPathX8}\Draw\Plugins64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: CheckX8DirExists 
Source: "C:\Users\Administrator\Desktop\xxx"; DestDir: "{code:ReadPath2017}\Draw\Plugins64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: CheckX17DirExists 
Source: "C:\Users\Administrator\Desktop\xxx"; DestDir: "{code:ReadPath2018}\Draw\Plugins64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: CheckX18DirExists 
Source: "C:\Users\Administrator\Desktop\xxx"; DestDir: "{code:ReadPath2019}\Draw\Plugins64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: CheckX19DirExists 
Source: "C:\Users\Administrator\Desktop\xxx"; DestDir: "{code:ReadPath2020}\Draw\Plugins64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: CheckX20DirExists 
Source: "C:\Users\Administrator\Desktop\xxx"; DestDir: "{code:ReadPath2021}\Draw\Plugins64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: CheckX21DirExists 
Source: "C:\Users\Administrator\Desktop\xxx"; DestDir: "{code:ReadPath2022}\Draw\Plugins64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: CheckX22DirExists 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值