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