[SOLVED] Error "Resource ... not found" using TResourceStream lazarus / 62-General ---------------------------------------------------------------------- Abelisto · 2018-02-28 15:47 It seems that I missed something very basic. I'v used this tutorial: http://wiki.freepascal.org/Lazarus_Resources#FPC_resources This is my test code: foo.pas Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program foo; {$mode objfpc}{$H+} uses    Classes; {$R foo.rc} function foo(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; lParam : PtrInt) : LongBool; stdcall;begin    Writeln(ResourceName);    Result := true;end; var    r: TResourceStream;    i: Byte;begin    {    for i := 1 to 24 do    begin        Writeln(i, ':');        EnumResourceNames(HINSTANCE, MAKEINTRESOURCE(i), @foo, 0);    end;    }    r := TResourceStream.Create(HINSTANCE, 'FOO', RT_RCDATA);end. foo.rc Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i FOO RT_RCDATA "foo.pas" And I got an error like: Code: [Select]An unhandled exception occurred at $00000000004270E6: EResNotFound: Resource "FOO" not found Looking into the binary I found that the data is presented. What I missed? ---------------------------------------------------------------------- rvk · 2018-02-28 16:42 Does your example really compile for you????????  (you could try 'RT_RCDATA') ---------------------------------------------------------------------- Abelisto · 2018-02-28 17:41 Quote from: rvk on February 28, 2018, 05:42:48 pmDoes your example really compile for you????????  (you could try 'RT_RCDATA') Yes, it is compilable. And it seems that r := TResourceStream.Create(HINSTANCE, 'FOO', 'RT_RCDATA'); fixes the problem. Thanks a lot sir ---------------------------------------------------------------------- rvk · 2018-02-28 18:15 Quote from: Abelisto on February 28, 2018, 06:41:23 pmYes, it is compilable.How was that compilable? In what unit is RT_RCDATA defined for you?? Is RT_RCDATA defined in Classes in an old version? ---------------------------------------------------------------------- Abelisto · 2018-02-28 19:09 Quote from: rvk on February 28, 2018, 07:15:36 pmQuote from: Abelisto on February 28, 2018, 06:41:23 pmYes, it is compilable.How was that compilable? In what unit is RT_RCDATA defined for you?? Is RT_RCDATA defined in Classes in an old version? It is defined in the System unit, in the resh.inc file in particular: https://svn.freepascal.org/svn/fpc/trunk/rtl/inc/resh.inc ---------------------------------------------------------------------- rvk · 2018-02-28 19:21 Ah, ok, that's why I didn't find it. It's NOT in system for Windows  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$ifndef MSWINDOWS }{ windows has this in the windows unit. It probably would better  fit into the classes/sysutils unit but because it is resource  related, I put it here (FK)}const  RT_CURSOR = MAKEINTRESOURCE(1);  RT_BITMAP = MAKEINTRESOURCE(2);  RT_ICON = MAKEINTRESOURCE(3);  RT_MENU = MAKEINTRESOURCE(4);  RT_DIALOG = MAKEINTRESOURCE(5);  RT_STRING = MAKEINTRESOURCE(6);  RT_FONTDIR = MAKEINTRESOURCE(7);  RT_FONT = MAKEINTRESOURCE(8);  RT_ACCELERATOR = MAKEINTRESOURCE(9);  RT_RCDATA = MAKEINTRESOURCE(10);  RT_MESSAGETABLE = MAKEINTRESOURCE(11);  RT_GROUP_CURSOR = MAKEINTRESOURCE(12);  RT_GROUP_ICON = MAKEINTRESOURCE(14);  RT_VERSION = MAKEINTRESOURCE(16);  RT_ANICURSOR = MAKEINTRESOURCE(21);  RT_ANIICON = MAKEINTRESOURCE(22);  RT_HTML = MAKEINTRESOURCE(23);  RT_MANIFEST = MAKEINTRESOURCE(24);{$endif MSWINDOWS }