VB6.0文件捆绑

main:
Dim FinalFile As String

Private Sub Command2_Click()
MsgBox Len(Text4)
End Sub

Private Sub Command3_Click()
SecondFile = Text2.Text '文件2
FirstFile = Text1.Text '文件1
FinalFile = Text3.Text '生成的文件

Open App.Path & “\1.exe” For Binary Access Write As #3 '创建生成的文件
Dim myarray() As Byte
myarray = LoadResData(101, “CUSTOM”) '资源里的文件

Put #3, , myarray '先写入资源里的文件

Put #3, 20481, Text4.Text '从资源文件大小+1处写入文件1

'Put #3, 20481 + file1size, second '资源文件+1处 + 文件1的大小处写入文件2
Put #3, 20481 + Len(Text4.Text), “71930” & Len(Text4) '资源文件+1 + 文件1大小 +文件2大小处写入 71930字符+文件1大小
Close #3

MsgBox “ok”
End
End Sub


suzhu:

Const mysize = 20480 '自身大小
Dim sbuff As String * 29
Dim FileSize As Long
Dim File1() As Byte

Private Sub Command1_Click()

Open ThePath & App.EXEName & “.exe” For Binary Access Read As #1
Get #1, LOF(1) - 28, sbuff
Call GetFileSize(sbuff)

'MsgBox FileSize '显示数据大小

ReDim File1(FileSize - 1)
Get #1, mysize + 1, File1 '从自身大小+1处开始读取

Close #1

Text1.Text = StrConv(File1, vbUnicode) '以文本方式显示

End Sub

Public Function ThePath() As String
If Right$(App.Path, 1) <> “” Then
ThePath = App.Path & “”
Else
ThePath = App.Path
End If
End Function

Public Function GetFileSize(sbuff)
Dim i As Integer
Dim s As String
For i = 1 To Len(sbuff) - 8
s = Mid(sbuff, i, 8)
If s = “71930” Then
FileSize = Val(Mid(sbuff, i + 8)) '以指定字符来确定文件大小
Exit For
End If
Next i
End Function

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老秃大哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值