I've tried this a bunch of ways so I'm assuming I'm doing something stupid. I'm trying to add a text file as a resource using an rc file but when i try and use the resource I get a resource not found error.
the rc file is mydata.rc and has only one line in it:
ASAMPLE RCDATA "samples/adminvoice.txt"
The file is found since if I change either the directory or the file name in for rc file I get an error when compiling.
Here is the code I'm using:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,LResources;
{$R mydata.rc}
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
RS: TResourceStream;
begin
RS := TResourceStream.Create(HInstance,'ASAMPLE', 'RT_RCDATA');
end;
end.
When I click the button the code gives me an error at the TResourceStream.Create line:
Project unformemu raised exception class 'EResNotFound' with message: Resource "ASAMPLE" not found
The rc file is getting compiled as I can find it in the lib/i386-win32 directory as mydata.res and even if I put that file in the main directory and change the mydata.rc to mydata.res I get the same error.
I've used this before but for a graphic file so I guess I'm missing something stupid but for the life of me I don't see what.
Ideas??