Search Tools Links Login

How to Append a file to an EXE


This is just to show you how to append a file to an executable. Could be handy if you wanna save maybe a tag to your exe file. Have not test it with very large files but small file works perfectly.

Original Author: Adriaan Putter

Side Effects

There could be problems with large files, I dont know.

Code

Private Sub AppendToExe(exefile$,filetoappend$)
  Open filetoappend$ For Binary As #1
  filedata$ = String(LOF(1), " ")
  Get #1, , filedata$
  Close #1
  Open exefile$ For Binary As #1
  f = LOF(1)
  Seek #1, f + 1
  Put #1, , "WAP"   'any identifer
  Put #1, , filedata$
  Close #1
  
End Sub
Private Sub ExtractFromExe(exefile$,filetoextr$)
  Open exefile$ For Binary As #1
  filedata$ = String(LOF(1), " ")
  Get #1, , filedata$
  Close #1
  pos = InStr(1, filedata$, "WAP")
  f$ = Mid$(filedata$, pos + 3)
  
  Open filetoextr$ For Binary As #2
  Put #2, , f$
  Close #2
    
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 70 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.