-
Run-time Compile ????
[Originally posted by Camilo]
Hi! I'm searching for a way to allow the user change certain text that is within the executable file, and then recompile the program with the new text and send this program by email. Have you seen those messagemates? I want to do somehing similar to that.
Any help would be GREATLY appreciated!!!
-
Re:Run-time Compile ????
[Originally posted by Andrea Batina]
You can change the text in your program using Hex Editor or you can make a language file.
Andrea Batina
-
Re:Run-time Compile ????
[Originally posted by neophile]
Append it to the end of the executable and have your program look for it at the end of itself. Write your program to look at the last byte of itself. If this is zero, this means it's blank.... any other value will tell you that it has been modified.
Here's some code I threw together based on some tests I did plus some stuff I read (I would have never come across this if it wasn't for you... thanks=):
Public Function ReadMyText() As String
ÿ ÿ Dim fn As Integer
ÿ ÿ Dim bLen As Byte
ÿ ÿ fn = FreeFile
ÿ ÿ Open App.Path & "\" & App.EXEName & ".exe" For Binary Access Read As fn
ÿ ÿ ÿ ÿ Get fn, LOF(fn), bLen
ÿ ÿ ÿ ÿ If bLen > 0 Then
ÿ ÿ ÿ ÿ ÿ ÿ ReadMyText = Space(bLen)
ÿ ÿ ÿ ÿ ÿ ÿ Get fn, LOF(fn) - bLen, ReadMyText
ÿ ÿ ÿ ÿ End If
ÿ ÿ Close fn
End Function
Public Sub CreateNewCopy(ByVal NewName As String, Optional ByVal Text As String)
ÿ ÿ Dim fn As Integer
ÿ ÿ Dim lSize As Long
ÿ ÿ Dim bCopy() As Byte
ÿ ÿ Dim bLen As Byte
ÿ ÿ If LCase(App.EXEName) <> LCase(NewName) And NewName <> "" Then
ÿ ÿ ÿ ÿ lSize = FileLen(App.Path & "\" & App.EXEName & ".exe")
ÿ ÿ ÿ ÿ fn = FreeFile
ÿ ÿ ÿ ÿ Open App.Path & "\" & App.EXEName & ".exe" For Binary Access Read As fn
ÿ ÿ ÿ ÿ ÿ ÿ Get fn, lSize, bLen
ÿ ÿ ÿ ÿ ÿ ÿ If bLen = 0 Then
ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ReDim bCopy(lSize - 1) As Byte
ÿ ÿ ÿ ÿ ÿ ÿ Else
ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ReDim bCopy(lSize - bLen - 2) As Byte
ÿ ÿ ÿ ÿ ÿ ÿ End If
ÿ ÿ ÿ ÿ ÿ ÿ Get fn, 1, bCopy
ÿ ÿ ÿ ÿ Close fn
ÿ ÿ ÿ ÿ fn = FreeFile
ÿ ÿ ÿ ÿ Open App.Path & "\" & NewName & ".exe" For Binary Access Write As fn
ÿ ÿ ÿ ÿ ÿ ÿ Put fn, , bCopy
ÿ ÿ ÿ ÿ ÿ ÿ bLen = Len(Text)
ÿ ÿ ÿ ÿ ÿ ÿ If bLen > 0 Then
ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ Put fn, , CByte(0)
ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ Put fn, , Text
ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ Put fn, , bLen
ÿ ÿ ÿ ÿ ÿ ÿ End If
ÿ ÿ ÿ ÿ Close fn
ÿ ÿ End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|