PaulLewis
Sep 20th, 2000, 10:42 PM
There is no doubt a way to do what you are trying to do, but in the meantime, here is an all-vb method for you.
To Test:
On a Form with a picturebox and a command button, add the following code.
1) Edit the code to point to an image file you want to use
2) Compile the code and note the exe byte size.
3) Edit the code and change the offset value in the SaveSpashImage Sub
4) Compile the code again
5) Copy the exe to another name like Tester.exe
6) Run Tester.exe and hit the append button.
7) Run Project1 and observe your splash image is present when the form loads.
Option Explicit
Private Sub SaveSplashImage()
Dim f, offset As Long
Dim picFile, exeFile As String
' this is the file to use as the splash image
picFile = "d:\!dev\bitmaps\snslogo-sm.jpg"
' this is the exe file you already have
exeFile = "d:\!dev\vb-world\SaveSplashImage\Project1.exe"
' this is the known length of the exe file
offset = 20480
'offset = 24576
' dim an array of bytes that will hold the image
ReDim bytes(FileLen(picFile)) As Byte
f = FreeFile
Open picFile For Binary As #f
' read the image
Get #f, , bytes
Close #f
f = FreeFile
Open exeFile For Binary As #f
' write the image
Put #f, offset, bytes
Close #f
End Sub
Private Sub GetSplashImage()
Dim f, offset As Long
Dim picFile, exeFile As String
' this is a temporary file
picFile = "c:\tmp.jpg"
' this is the exe that is running
exeFile = App.Path & "\" & App.EXEName & ".exe"
' this is the known length of the exe
offset = 20480
' byte array to store the image
ReDim bytes(FileLen(exeFile) - offset) As Byte
f = FreeFile
Open exeFile For Binary As #f
' read the image
Get #f, offset, bytes
Close #f
f = FreeFile
Open picFile For Binary As #f
' save the image as a tmp file
Put #f, , bytes
Close #f
On Error Resume Next
' use vb to read the image
Set Picture1.Picture = LoadPicture(picFile)
' kill the tmp file
Kill picFile
On Error GoTo 0
End Sub
Private Sub Command1_Click()
SaveSplashImage
End Sub
Private Sub Form_Load()
GetSplashImage
End Sub
Hope it is useful
To Test:
On a Form with a picturebox and a command button, add the following code.
1) Edit the code to point to an image file you want to use
2) Compile the code and note the exe byte size.
3) Edit the code and change the offset value in the SaveSpashImage Sub
4) Compile the code again
5) Copy the exe to another name like Tester.exe
6) Run Tester.exe and hit the append button.
7) Run Project1 and observe your splash image is present when the form loads.
Option Explicit
Private Sub SaveSplashImage()
Dim f, offset As Long
Dim picFile, exeFile As String
' this is the file to use as the splash image
picFile = "d:\!dev\bitmaps\snslogo-sm.jpg"
' this is the exe file you already have
exeFile = "d:\!dev\vb-world\SaveSplashImage\Project1.exe"
' this is the known length of the exe file
offset = 20480
'offset = 24576
' dim an array of bytes that will hold the image
ReDim bytes(FileLen(picFile)) As Byte
f = FreeFile
Open picFile For Binary As #f
' read the image
Get #f, , bytes
Close #f
f = FreeFile
Open exeFile For Binary As #f
' write the image
Put #f, offset, bytes
Close #f
End Sub
Private Sub GetSplashImage()
Dim f, offset As Long
Dim picFile, exeFile As String
' this is a temporary file
picFile = "c:\tmp.jpg"
' this is the exe that is running
exeFile = App.Path & "\" & App.EXEName & ".exe"
' this is the known length of the exe
offset = 20480
' byte array to store the image
ReDim bytes(FileLen(exeFile) - offset) As Byte
f = FreeFile
Open exeFile For Binary As #f
' read the image
Get #f, offset, bytes
Close #f
f = FreeFile
Open picFile For Binary As #f
' save the image as a tmp file
Put #f, , bytes
Close #f
On Error Resume Next
' use vb to read the image
Set Picture1.Picture = LoadPicture(picFile)
' kill the tmp file
Kill picFile
On Error GoTo 0
End Sub
Private Sub Command1_Click()
SaveSplashImage
End Sub
Private Sub Form_Load()
GetSplashImage
End Sub
Hope it is useful