如何把一个程序和它的数据文件合在一起(50分给你)

netpower 2000-07-11 10:01:00
如何把一个程序和它的数据文件合在一起?
如:
一个能打开AA.BMP文件的程序AA.EXE
要看AA.BMP时就用AA.EXE
这要用到AA.BMP和AA.EXE这两个文件
我想问能把这两个文件合成一个BB.EXE
这样就只用到一个文件了!!
你们明白吗??
(当然我的程序不是用来看图的,数据文件也不是BMP了!
只是说明我想做的事)
...全文
397 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
czh918 2000-07-14
  • 打赏
  • 举报
回复
将图片文件用程序读取下来,生成一个vb的模块,该模块含有图片文件的变量,将该模块加入工程,编译后即可
liyang 2000-07-14
  • 打赏
  • 举报
回复
那你按我前面的方法,运行程序时,直接读取相应数据放在变量里,不写成文件不就行了?!:)
netpower 2000-07-13
  • 打赏
  • 举报
回复
liyang:
你好!
感谢你对我的文章的回复!
不过,你所说的意思是把两个文件和成一个文件!运行它后,还是要生成两个文件!
而我的意思是,只希望在硬盘上只有一个文件,而不是两个!因为我怕用户修改我的数据文件!请你多看看我的提问,我相信这五十分非你莫属!嘿嘿~^_^
liyang 2000-07-12
  • 打赏
  • 举报
回复
是啊。winzip 的self extractor!
TopHead 2000-07-12
  • 打赏
  • 举报
回复
哦,自己执行的时候把自己给解开成几个文件:)
liyang 2000-07-12
  • 打赏
  • 举报
回复
tophead:
你也很厉害呀。回答不少难题。最近来了bluewater,也是个很厉害的高手.
可以的。程序一就是这个自解放的exe.
试过,exe在执行时可以对自己进行读操作。我原来不知道,试过了,才晓得。
TopHead 2000-07-12
  • 打赏
  • 举报
回复
呵呵,liyang佩服佩服,问一句程序2生成的打包后的文件能自解开吗?
liyang 2000-07-12
  • 打赏
  • 举报
回复
程序2 (打包程序)

'前面自己加选择文件的代码,例如文件路径存放于mstrFile内。
private type DATA_INFO
strFileName as string
strPath as string '(如果你想解到别的路径下,可以定义一系列宏)
lFileLen as long
end type

private sub AddFile
dim iFile as integer
dim iDestFile as integer
dim bytBuffer() as byte
dim strDestPath as string
dim FileInfo as FILE_INFO

if dir(mstrFile)<>"" then
redim bytbuffer(filelen(mstrfile))
FileInfo.strFIlename='filename
FileInfo.lFileLen=filelen(mstrfile)
iFile=freefile
open mstrfile for binary access read as ifile
idestfile=freefile
open strdestpath for binary access write as idestfile
get ifile,,bytbuffer
put idestfile,,fileinfo
put idestfile,,bytbuffer
close idestfile
close ifile
endif

ens sub


另:程序一有点问题,应该是:
dim FileInfo as FILE_INFO
open App.Path & "\" & app.exename & ".exe" for binary access read as ifile
get ifile,,FileInfo
redim bytBuffer(FileInfo.lFIlelen)
...

哎,对于这道题来说,分太少了点。我以前花了一下午才写出来。:)
要想加多个文件,改为数组,再在添加文件时把数据文件数量先写进去。
有问题再问我吧
祝,成功!

liyang 2000-07-12
  • 打赏
  • 举报
回复
我做过一个自解压的。实际上就是一个脱壳程序。首先,你要先把你的exe编译出来,看它有多大,存为一个常量。再另外做一个程序,专门进行合并。如:
程序一(解包)
private const MYLENGTH=23560

private mlFileCount as long
private type DATA_INFO
strFileName as string
strPath as string '(如果你想解到别的路径下,可以定义一系列宏)
lFileLen as long
end type

private sub ExtractData
dim iFile as integer
dim iDestFile as integer
dim strDestPath as string
dim bytBuffer() as byte
dim lFileLen as long

ifile=freefile
open App.Path & "\" & app.exename & ".exe" for binary access read as ifile
get ifile,,lfilelen
iDestFIle=freefile
open strDestPath for binary access write as idestfile
redim bytbuffer(lfilelen-1)
get iFile,,bytbuffer
put idestfile,,bytbuffer
close idestfile
close ifile
end sub
fourway 2000-07-11
  • 打赏
  • 举报
回复
这个问题我见过!有人写过!
不过现在记不得在哪看到的了!
最后好象要copy a+b c合成一个文件!在程序中
读B时,把文件指针移到a的大小+1处!就是B的开始处
netpower 2000-07-11
  • 打赏
  • 举报
回复
TopHead
数据文件是自己写的了专用的文件
TopHead 2000-07-11
  • 打赏
  • 举报
回复
你要得到的数据文件是那种类型的数据啊?
TopHead 2000-07-11
  • 打赏
  • 举报
回复
这个好像有点意思:)

想想。。。

I am thinking....
sunjian 2000-07-11
  • 打赏
  • 举报
回复
把数据文件编辑可执行文件的资源当中,不就可以了

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧