I'm using Delphi XE Starter. I've created a CCs.RC file and added that file to the project. A typical line in my CCs.RC file looks like this:
Danish1cc Text Danish1.cc
Directly after an Implementation line I've added
{$R CCs}
When I try to read this file into an existing stringlist, I get an [EResNotFound][1]
error message. Here's the code I've used to try and read the file:
procedure LoadStringListFromResource(const ResName: string;SL : TStringList);
var
RS: TResourceStream;
begin
RS := TResourceStream.Create(HInstance, ResName, RT_RCDATA);
try
SL.LoadFromStream(RS);
finally
RS.Free;
end;
end;
///
LoadStringListFromResource('Danish1cc',MySL)
My goal is to embed the file in my EXE and of course be able to read it :) Thank you for any help.
Your resource's type doesn't match. In your *.RC file you use TEXT
whereas in your code you use RCDATA
.
You must either change your *.RC file to
Danish1cc RCDATA Danish1.cc
Or you must change
RS := TResourceStream.Create(HInstance, ResName, RT_RCDATA);
to
RS := TResourceStream.Create(HInstance, ResName, 'Text');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With