-
Hi
I was just wondering if someone could tell me if there was a way to extract files, out of a resource files?, Because I want distribute just 1 big .exe file and on the first time its run I want it to extract, a few pictures, a few text files, and a couple of .ocx files. Is there a way to do this?
thanx
-
You can use WinZip and create a self extracting zip file. It actually creates an exe that contains the files you specify and extracts them to the directory that you specify.
-
Hi thanx for repying but I actually was wondering if I included files in a resource file if there was a way to extract these files out of them. So to exclude the need to use a third party setup creator or decompresser.
-
If you have VB6 installed, then you already have a Resource Editor.
To put the file in the resource: From the Add-Ins menu select Add-In Manager.... From the list select (put a check mark) a VB6 Resource Editor. Then, from the Project menu select Add New Resource File. A common dialog will be shown to give a name to your new resource file, do so (don't worry, this file will not be needed after you compile your program). Now, you will notice that in project explorer you would have a resource file added. Now, double click on that file. You will get the Resource Editor. From the toolbar select secon icon from the right (the icon called Add Custom Resource... Select the appropriate file (EXE). Notice that editor will create an ID for each item you add. You can keep the default or change them to different ID by double click on each item. Close the Resource Editor. Let's say you keep the default IDs. Now, the programming part.
Here is the generic routine that you can use:
Code:
Public Sub RunEXEFromResource(pintResourceID As Integer)
Dim bytArr() As Byte
Dim intFFN As Integer
Dim strPath As String
bytArr = LoadResData(pintResourceID, "CUSTOM")
strPath = App.Path & IIf(Right(App.Path, 1) = "\", MyEXE.exe", "\MyEXE.exe")
intFFN = FreeFile
Open strPath For Binary As intFFN
Put #intFFN, , bytArr
Close #intFFN
Shell strPath, vbNormalFocus
End Sub
Usage: RunEXEFromResource ResourceID
Example: Call RunEXEFromResource(101)
Where 101 is a resource ID.