Page 1 of 1

How add multiple strings in exe?

Posted: Wed Dec 17, 2008 2:14 pm
by Mark.s
My question is in subject. But, how i can add an multiplelines text to exe,
without destroying that exe. i need an example of that.

Text is in array, like this:

Code: Select all

Dim Array.s(2)
Array(1) = "newline"
Array(2) = "line 2"

Posted: Wed Dec 17, 2008 2:42 pm
by Inf0Byt3
You mean like this?

Code: Select all

MyString.s = #CRLF$+"This"+#CRLF$+"is"+#CRLF$+"a"+#CRLF$+"multiline"+#CRLF$+"string"
MessageRequester("",Mystring)
Compile as exe then look inside with notepad :).

Posted: Wed Dec 17, 2008 3:11 pm
by Mark.s
Inf0Byt3 wrote:You mean like this?
Sorry my bad English, but i mean somelike this:

Code: Select all

Dim array.s(1)

array.s(0) = "Test"
array.s(1) = "another test"

Dim message.s(1)
    
pfile.s="test.exe"
psize=FileSize(pfile) 
file=OpenFile(0, pfile) 

If file 
  FileSeek(0,psize)  
  For i = 0 To 1
  	WriteStringN(0,array.s(i)) 
    Debug array.s(i)
  Next i
  MessageRequester("Status", "Added text to exe!") 
  CloseFile(0) 
EndIf

fsize=FileSize(pfile) 
file=ReadFile(0, pfile) 

If file 
  FileSeek(0,psize) 
  For i = 0 To 1
    message.s(i)=ReadString(0) 
    MessageRequester("Success!", message(i))  
    Debug message.s(i)
  Next i
  CloseFile(0) 
EndIf
But problem is now: This not work on compiled exe's, its work only in editor.

So when i start compiled exe, there comes messagebox, but in msbox
there no are text. So what need do to, get that working on exes?

Posted: Wed Dec 17, 2008 3:27 pm
by srod
Well, you cannot append strings to an exe whilst it is running as Windows locks the file completely.

What you can do is append strings to the exe whilst it is not running and if you append some kind of pointer to point to the first string, then there is nothing stopping you opening the exe for reading whilst it is running and thus retrieving the strings etc.

Take a self-extracting archive for example, here (typically) a copy of the running exe would be used and data appended to that etc.