Question

I'm using Inno Setup to create an installer for my application. I'm currently filling a combobox (TNewComboBox) with the names of the Web sites on the current machine's IIS install. Now what I really want to do is store the COM object alongside the string in the objects property of the combo but keep getting type mismatch errors, even when wrapping the COM object in a TObject(xxx) call.

I've read in other places that the TStrings object should have an AddObject method but it doesn't seem to be present in Inno Setup/Pascal Script.

Was it helpful?

Solution

Delphi's TStrings class does have AddObject method but it seems that Inno's PascalScript TStrings wrapper doesn't. However, you should be able to set it like this:

  Index := Strings.Add('text');
  Strings.Objects[Index] := TObject(xxx);

OTHER TIPS

Do not cast, just wrap it in an object.

 Type
     TMyObjectForStringList = class 
                                fCOMThingy : variant;   // or ole variant
                                constructor create(comthingy:variant); 
                               end;

  constructor TMyObjectForStringList.Create(comthingy:variant);
  begin
    fcomthingy:=comthingy;
  end;

 myStringList.addobject(astring,TMyObjectForStringList.Create(avariant));

Do not forget to free it afterwards (Delphi's tstringlist lacks "deallocate all" functionality)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top