stevenvh.net

Resources in Delphi

The code below shows how to use resources to load multiline text into a TStringList.

Code

  procedure LoadStringListFromResource(aResID: string; aSL: TStringList);
    var
      RS: TResourceStream;
    begin
      RS := TResourceStream.Create(hInstance, aResID, RT_RCDATA);
      try
        aSL.LoadFromStream(RS);
      finally
        RS.Free;
      end;
    end;
      

Issues

Delphi 11.3 seems to have a bug that requires you to set the resource name twice in the resource editor. When you set the resource name and look into the .rc file you'll see that the resource name will still be the default "resource_1". Making a small change in the name and saving it again fixes it.