Click to See Complete Forum and Search --> : ? can i make a self extract exe ?
BlackRose
Jan 13th, 2000, 01:18 AM
hi...
i want to make exe inside exe like winzip self extract .
code or hints , .
------------------
BlackRose
what exactly do you mean? All the setup information that you need is available with VB to create setup programs etc
Merry VIP
Jan 13th, 2000, 03:09 AM
With WinZip comes possibility to make self-ectract exes. Though, it is really limited. You can only make file that is extracted to some directory (like that it includes the setup files).
I've also heard at other programs, which make only one exe that have all the files inside and itself is real setuplike. I think they are mainly MustBePaid-programs.
Vesa Piittinen
Bart
Jan 13th, 2000, 03:10 AM
I'm working on such code right now! If you can wait a while I can maybe add some type of compression too. But I don't know yet how to do this. If you need the code urgent, mail me.
lumin
Jan 13th, 2000, 04:37 AM
hey.
this is a great program and its free. you can make your files into 1 self-extracting file just like winZip but this program is better. http://www.gkware.com/gksetup/
-Lumin
Lyla
Jan 13th, 2000, 08:15 AM
Hi BlackRose.
I haven't tried it yet. Check it out:
http://www.planet-source-code.com/vb/default.asp?lngCId=3147&lngWId=1
Good Luck.
Bad5887
Jan 13th, 2000, 09:10 AM
hehe i made the exact thing u want in DOS QB and now i made it for VB it works fast adn it is awesome, the vb one still needs to look pretty ill finish it whge n i m done, to get the DOS one get it at my site: http://bad5887.homepage.com
Ruchi
Jan 13th, 2000, 12:59 PM
This source code is from the web.
Ruchi
---------------------------------------------
In this example, PROGA.EXE is this program, PROGB.EXE is the EXE you are going to attach, and PROGC will be the new executable containing both PROGA and PROGB...
First, put the following code in a MODULE. This code will execute a command and wait for it to end.
Public Const INFINITE = -1&
Private Declare Function OpenProcess Lib "kernel32" (ByVal _
dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessID As Long) As Long
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Public Function ExecCmd(cmdline$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
' Initialize the STARTUPINFO structure:
start.cb = Len(start)
' Start the shelled application:
ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
' Wait for the shelled application to finish:
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
Call GetExitCodeProcess(proc.hProcess, ret&)
Call CloseHandle(proc.hThread)
Call CloseHandle(proc.hProcess)
ExecCmd = ret&
End Function
----------------------------------------------------------
Then put the following code in your program... For this example, I am using a commandbutton:
Private Sub Command1_Click()
'THIS CONSTANT MUST BE CHANGE TO THE SIZE
'OF THE ATTACHED EXE IN BYTES
Const AttachedExeSize = 8704
Dim TempFnum As Long
Dim TempExe As String
Dim MySelfFnum As Long
Dim MySelfExe As String
Dim MySelfSize As Long
Dim lByte As Byte
'BUILD THE PATH TO MYSELF
MySelfExe = App.Path
If Not Right$(MySelfExe, 1) = "\" Then MySelfExe = MySelfExe + "\"
MySelfExe = MySelfExe + App.EXEName + ".EXE"
'GET A FREE FILENUMBER TO OPEN MYSELF AND OPEN MYSELF
MySelfFnum = FreeFile
Open MySelfExe For Binary Access Read As MySelfFnum
'FIND THE START OF THE SECOND EXE
MySelfSize = LOF(MySelfFnum)
Seek MySelfFnum, MySelfSize - AttachedExeSize + 1
'BUILD THE PATH TO THE TEMP FILE
TempExe = Environ("TEMP")
If Not Right$(TempExe, 1) = "\" Then TempExe = TempExe + "\"
TempExe = TempExe + "TMP" + Format(Now, "hhnnss") + ".EXE"
'GET A FREE FILENUMBER TO THE TEMP FILE AND OPEN IT
TempFnum = FreeFile
Open TempExe For Binary Access Write As TempFnum
'EXTRACT THE FILE
Do
Get #MySelfFnum, , lByte
If EOF(MySelfFnum) = True Then Exit Do
Put #TempFnum, , lByte
Loop
'CLOSE THE FILES
Close MySelfFnum
Close TempFnum
'EXECUTE AND WAIT FOR THE EXTRACTED EXE TO COMPLETE
ExecCmd TempExe
'DELETE THE EXTRACTED EXE
Kill TempExe
End Sub
----------------------------------------------------------
Make sure you change the constant AttachedExeSize to be the size of the EXE you are attaching in BYTES.
Compile your program.
In a dos command window, do the copy to attach the file:
COPY /B PROGA.EXE + PROGB.EXE PROGC.EXE
Run PROGC.EXE... You program will run. when you click the commandbutton, PROGB.EXE will be extracted to a temp EXE in the TEMP directory and executed. Once PROGB terminates, the temp EXE will be deleted!
Lyla
Jan 13th, 2000, 03:13 PM
If you may, What are the possible uses for this method?
Thanx.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.