Reputation: 505
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.
Upvotes: 7
Views: 6084
Reputation: 489
I think the problem is with this line - {$R CCs}
You have compiled a resource file, isnt that file called CCs.res?
if so that line in your code should be {$R CCs.res}
Upvotes: 0
Reputation: 8141
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');
Upvotes: 10