Please, share your code. It will be easier to have an idea on how to do it..
Thanks a lot
Sure.
Here is a little test program I wrote over 20 years ago. Some of the comments refer to Windows 95, you can ignore them but, they apply to current versions of Windows too.
When you load the .lpr select "Simple program" not anything else because if you do, Lazarus will overwrite the .res file with a res file it creates and doesn't even warn you that the res file is overwritten.
Also, the .rc file included is compiled with Borland's resource compiler (BRCC32.exe) I doubt it can be compiled with something else.
This test program defines binary data directly in the .rc file (have a look in the .rc if you are curious.) To replace that data with your executable, use ResourceHacker to edit the .res file (or the resulting program directly, your choice.) You will find resource hacker at
http://www.angusj.com/resourcehacker/ it is a very nice and very useful utility.
In this test program, the binary data is displayed in the main window during the processing of the WM_PAINT. In the case of an embedded executable, it's quite unlikely you'd want to do that. Instead you'd probably want to load the resource and write it out in some other part of your program. Where the code should go in your program is up to you.
I know Lazarus most likely provides a way to do this with less code but, as I stated before, I only use OS functions, Windows API in this case, therefore I have no clue how the same thing is done the Lazarus/FPC way.
You're welcome. Hopefully, it will be helpful to you in spite of being pure Windows API.