Search code examples
inno-setupdllimportpascalscript

Is it possible to receive a Stringlist from C++ DLL?


I need to get a list of string from my C++ DLL. I know how to use the DLL and already do it several times in the [code] section with simple data types e.g. Boolean or Integer. However now I need to get a list of string to fill a combo box this way, but I've no idea where I could start. I've read that if I want to get a String I need to allocate memory on Inno Setup side.

So my questions are:

  • How can I receive a stringlist from my C++ DLL function or is it possible to fill a combo box on C++ side and return this one instead? - If both is possible what would be easier on Inno Setup side?

Thanks for help.


Solution

  • You can populate the Inno Setup combo box in your C++ code, if you pass its HWND to the DLL (use TWinControl.Handle).


    If you want to pass a list of strings from DLL back to the Inno Setup, I'd suggest you to add two functions to the DLL:

    function GetComboBoxItemsCount: Integer;
    procedure GetComboBoxItemString(Index: Integer; Str: PChar; MaxLength: Integer);
    

    Make GetComboBoxItemsCount return number of items. And then call GetComboBoxItemString in a loop to retrieve individual strings.