在VB6中将文件嵌入到EXE文件中 [英] Embed a file into EXE file in VB6

查看:14
本文介绍了在VB6中将文件嵌入到EXE文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 VB6 中制作一个安装程序,它将安装该程序所需的所有文件.

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

我使用 CSV 文件存储数据并使用以下方式读取数据:

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

file="C:usersadmindesktop	able.csv"
Open file For Input As fnum

但是,EXE 文件无法在另一台笔记本电脑上执行,因为我收到错误file not found".

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

那么:如何将此 CSV 文档嵌入到 .EXE 文件中,以便程序可以在任何 Windows PC 上运行?

推荐答案

  1. 打开项目,Add-Ins菜单项,打开Add-In管理器&双击VB6资源编辑器加载它,关闭管理器.

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

点击Project菜单项,然后点击底部的Add new Resource File.输入它的文件名 &将其保存在您的代码文件所在的目录中.

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.

Project Explorer 树中双击新 Related Documents 节点中的 XXX.RES.

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

从弹出的窗口的工具栏中选择添加自定义资源

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

浏览到您的 .csv 并添加它,您应该会看到它添加为 CUSTOM101

Browse to your .csv and add it, you should see it added as CUSTOM101

现在它将在编译时嵌入到 exe 中.如果文件发生更改,请将其重新添加到资源中,每个条目有 64k 的限制.

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.

在运行时将其加载到代码中:

To load it in code at runtime:

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

这篇关于在VB6中将文件嵌入到EXE文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆