* * *

Author Topic: [SOLVED] Full handling of text files integrated in exe file  (Read 916 times)

yurkad

  • Full Member
  • ***
  • Posts: 107
The first part of this problem is integrate any files to exe file. This is solved here:
https://www.thoughtco.com/inside-the-delphi-exe-1058211

Second part of this problem is get some text file from exe file and put it in disc or in memory for edit.

Third  part of this problem is insert edited text file back in exe file.

One variant of this can be simple: concatenate all files into exe file. But after this is necesary know point of begin for each file. This point will be change each time.
So is necesary have several variables from exe, which can be changed and saving in exe file after runtime.

Each operation (integration and getting text files and editing them) will make same app from exe file.

So, please, how can be solve this problem?
 



« Last Edit: June 09, 2017, 05:20:35 pm by yurkad »

sky_khan

  • Guest
Re: Full handling of text files integrated in exe file
« Reply #1 on: May 17, 2017, 05:35:35 pm »
The link you gave does not "concatenate all files". It modifies resources of executable by WinAPI. If you're on Windows you can read or update any resource by its ID or name individually, again, by WinAPI.
Your question is so generic.  Dont be lazy and try to write it yourself first.
I reject to give an answer until I see some of your own code :)

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Full handling of text files integrated in exe file
« Reply #2 on: May 17, 2017, 05:42:29 pm »
@SkyKhan, you say, that
Quote
you can read or update any resource by its ID or name individually

If realmente can be update in runtime any resource by its ID, then it is solution.

I will search about  "update in runtime resource".

Thanks.

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Full handling of text files integrated in exe file
« Reply #3 on: May 17, 2017, 05:54:35 pm »
It seems it can not be update resource in runtime. 

Handoko

  • Hero Member
  • *****
  • Posts: 1325
  • My goal: build my own game engine using Lazarus
Re: Full handling of text files integrated in exe file
« Reply #4 on: May 17, 2017, 06:09:26 pm »
This is an interesting topic. So I googled the web. They said it can.

http://stackoverflow.com/questions/13218777/can-i-edit-resource-file-at-runtime

https://msdn.microsoft.com/en-us/library/windows/desktop/ms648049%28v=vs.85%29.aspx

I will be happy if it can also be used on Linux. I ever had similar case, which I solved using a not-so-good trick:
http://forum.lazarus.freepascal.org/index.php/topic,36674.msg244647.html#msg244647

sky_khan

  • Guest
Re: Full handling of text files integrated in exe file
« Reply #5 on: May 17, 2017, 08:45:36 pm »
On windows, you can read or update any resource by its ID or name individually of an executable...
but not while it is running. At least without using dirty hacks.

Besides, if you install your self-modifying application in "Program Files" your users will not have write permission for it.
So if you want to write an application like an IDE or like a compiler which creates/modifies executables other than itself you can use WinAPI to do it.
Otherwise you really should store your settings/texts elsewhere like in a normal data file in User or AppData directory.

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Full handling of text files integrated in exe file
« Reply #6 on: May 17, 2017, 10:19:14 pm »
@Handoko, @SkyKhan, thanks.

I will try to make something in Lazarus pure.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5529
Re: Full handling of text files integrated in exe file
« Reply #7 on: May 17, 2017, 10:35:48 pm »
you might want to have a look at FPC's fcl-res package.

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Full handling of text files integrated in exe file
« Reply #8 on: May 18, 2017, 12:09:33 am »
@marcov, thank for advice.

sky_khan

  • Guest

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Full handling of text files integrated in exe file
« Reply #10 on: June 09, 2017, 04:57:01 pm »
@sky_khan, thank you very much. I hope that this will close my question.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus