Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed a file into EXE file in VB6

Tags:

embed

exe

vb6

I am trying to make a setup program in VB6 that will install all the files that are required for the program.

I use a CSV file to store data and read it using:

file="C:\users\admin\desktop\table.csv"
Open file For Input As fnum

However the EXE file cannot be executed on another laptop as I get the error "file not found".

So: how to embed this CSV document into the .EXE file so that the program can run on any Windows PC?

like image 570
Santosh Avatar asked Aug 10 '12 06:08

Santosh


1 Answers

  1. Open the project, Add-Ins menu item, open the Add-In manager & double click the VB6 Resource Editor to load it, close manager.

  2. Click Project menu item then Add new Resource File at the bottom. Enter a file name for it & save it in the directory with your code files.

  3. From the Project Explorer tree double click XXX.RES from the new Related Documents node.

  4. Select Add Custom Resource from the toolbar in the window that pops up

  5. Browse to your .csv and add it, you should see it added as CUSTOM\101

  6. It will now be embedded into the exe at compile time. If the file changes, re-add it to the resource, there is a 64k limit per entry.

  7. To load it in code at runtime:

    strCSV = strconv(LoadResData(101, "CUSTOM"), vbunicode)

like image 193
Alex K. Avatar answered Oct 10 '22 03:10

Alex K.