Yes, it is possible and quite feasible. There isn't much call for this sort of thing but I use the technique whenever I need to distribute a package containing programs I don't want the user to copy or run without authorization.
I call it "piggy backing". It amounts to appending one or more executable files to the application EXE. When they are needed, they are extracted, executed and deleted without the user's knowledge. This is quite kosher as far as Windows is concerned. The EXE file header directs the OS to load only the program into memory and ignore anything appended to the program. It is also legal to read a running EXE but not to write to it (you would get some nasty access violations).
Here is an example of "piggy backing" an EXE. You will need a list box and a couple of command buttons for the demonstration:
[tt]
' This structure will hold the
' EXE information after the files
' are appended to your program.
Private Type PiggyBack
StartByte As Long
FileSize As Long
EXEname As String * 32
End Type
Dim EXEinfo(6) As PiggyBack
Private Sub MakeExe_Click()
' This sub stores the contents of
' several programs at the end of your
' application EXE. This would be done
' from a separate program or from within
' the VB IDE.
'
' Fill an array with the names of the
' programs you want to add to your
' executable. (These are just examples.)
EXEinfo(0).EXEname = "Echat.EXE"
EXEinfo(1).EXEname = "Invis.EXE"
EXEinfo(2).EXEname = "List.COM"
EXEinfo(3).EXEname = "MakBlank.EXE"
EXEinfo(4).EXEname = "SetSer.EXE"
EXEinfo(5).EXEname = "Vtest.EXE"
EXEinfo(6).EXEname = "Win.COM"
' This is the name of your program.
MyExe$ = "PigiBack.exe"
' You would probably use...
' App.ExeName & ".EXE" instead.
F1 = FreeFile
Open MyExe$ For Binary As #F1
Get #F1, LOF(F1) - 3, Test&
' Check to see if the last 4 bytes of the EXE
' contain a file size.
If Test& > 0 Then
Close #F1
MsgBox "File has already been piggybacked."
Exit Sub
End If
' Read the contents of the program files
' and appendf them to your app EXE.
For Rep = 0 To UBound(EXEinfo)
With EXEinfo(Rep)
f2 = FreeFile
Open .EXEname For Binary As #f2
G$ = String$(LOF(f2), 0)
.FileSize = Len(G$)
Get #f2, 1, G$
Close #f2
.StartByte = LOF(F1) + 1
Put #F1, , G$
End With
Next
' Write the file information
' records at the end of the EXE.
For Rep = 0 To UBound(EXEinfo)
Put #F1, , EXEinfo(Rep)
Next
Close #F1
End Sub
Private Sub ExtractExes_Click()
' This sub just retrieves the stored
' program names and places them in
' a list box.
MyExe$ = "PigiBack.exe"
F1 = FreeFile
Open MyExe$ For Binary As #F1
Get #F1, LOF(F1) - 3, Test&
' Check to see if the last 4 bytes of the EXE
' contain a file size.
If Test& = 0 Then
Close #F1
MsgBox "File has not been piggybacked yet."
Exit Sub
End If
RecSize = Len(EXEinfo(0))
' Get the file information records.
For Rep = 0 To UBound(EXEinfo)
Get #F1, LOF(F1) - (RecSize * (Rep + 1)) + 1, EXEinfo(Rep)
List1.AddItem EXEinfo(Rep).EXEname
Next
Close #F1
End Sub
Private Sub List1_Click()
' Extract and run a program.
Fname$ = Trim$(List1.Text)
For Rep = 0 To UBound(EXEinfo)
If InStr(Fname$, EXEinfo(0).EXEname) > 0 Then
MyExe$ = "PigiBack.exe"
F1 = FreeFile
Open MyExe$ For Binary As #F1
G$ = String$(EXEinfo(0).FileSize, 0)
Get #F1, EXEinfo(0).StartByte, G$
Close #F1
' Extract the program to the TEMP directory.
Fname$ = Environ$("TEMP"

& "\" & Fname$
f2 = FreeFile
Open Fname$ For Binary As #f2
Put #f2, 1, G$
Close #f2
Exit For
End If
Next
DoEvents
Shell Fname$, vbNormalFocus
' You would probably want to wait until
' the program is finished and then clean up
' by deleting it from the temp directory.
End Sub
[/tt]
Have fun.
Alt255@Vorpalcom.Intranets.com