1

What I really want to do is have Inno Setup uninstall a component, if it's unchecked in a subsequent run. But, if I'm not mistaken, that is not possible in Inno Setup (actually, correct me, if I'm wrong on this).

So, instead I want to make check function to see if a component is installed, so I can hide it during subsequent runs. I'm not sure where else to get that info other than the Inno Setup: Selected Components under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\[AppName]_is1.

Now the problem is my Inno Setup: Selected Components is as,as2,as3,bs,bs2,bs3.
How can I detect as, without detecting as2 or as3?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

1

Indeed, Inno Setup does not support uninstalling components.


For a similar question (and maybe better), see:
Inno Setup: Disable already installed components on upgrade


For checking of installed components, I'd rather suggest you to check for existence of files corresponding to the component.


Anyway, to answer your actual question: If you want to scan the Inno Setup: Selected Components entry, you can use this function:

function ItemExistsInList(Item: string; List: string): Boolean;
var
  S: string;
  P: Integer;
begin
  Result := False;
  while (not Result) and (List <> '') do
  begin
    P := Pos(',', List);
    if P > 0 then
    begin
      S := Copy(List, 1, P - 1);
      Delete(List, 1, P);
    end
      else
    begin
      S := List;
      List := '';
    end;

    Result := (CompareText(S, Item) = 0);
  end;
end;

Note that the uninstall key can be present in HKCU (not in HKLM) under certain circumstances.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • OK, this works, but I'm not gonna be using this. I misunderstood what inno does to `Inno Setup: Selected Components`. I thought it would ADD the components to the value, but it actually replaces the entire value, which renders this whole process useless. I'll take a look at the solution in the post you linked, but I guess I'll end up checking for installed files, as you suggested. – George Hovhannisian May 29 '17 at 05:52
  • Actually, that post says the same thing. `Inno Setup: Selected Components` is being rewritten during each install, so it's kinda useless for porposes like this. File check it is, then... – George Hovhannisian May 29 '17 at 05:55
  • If you just disable the already installed component (and keep it checked), you will have all components in the `Inno Setup: Selected Components`. – Martin Prikryl May 29 '17 at 06:07
  • I applied the check functions on the components, the result is `true`, so those components are not visible on second run, and they are unchecked by default (since Inno sees them as already installed). – George Hovhannisian May 29 '17 at 06:12