Private Sub Command1_Click() '合并
Dim abc() As Byte '声名数组
Open "c:\c.exe" For Binary As #1 '指定合并后的路径
Open "c:\a.exe" For Binary As #2 '以二进制打开文件,将二进制保存到#2
Open "c:\b.exe" For Binary As #3 '以二进制打开文件,将二进制保存到#3
ReDim abc(1 To LOF(2)) '定义数组范围,LOF(2)为#2文件的大小
Get #2, , abc '将#2保存到数组abc中
Put #1, , abc '将数组abc保存到"c:\c.exe"
ReDim abc(1 To LOF(3)) '定义数组范围,LOF(3)为#3文件的大小
Get #3, , abc '将#3保存到数组abc中
Put #1, , abc '将数组abc叠加保存到"c:\c.exe"
Close #3
Close #2
Close #1
End Sub
Private Sub Command2_Click() '拆分文件一
Dim abc() As Byte '声名数组
Open "c:\新文件a.exe" For Binary As #1 '指定提取出来的文件a的路径
Open "c:\a.exe" For Binary As #2 '只为取文件a的大小做准备,如果己知a的大小可省去此步
Open "c:\b.exe" For Binary As #3 '只为取文件b的大小做准备,如果己知b的大小可省去此步
Open "c:\c.exe" For Binary As #4 '以二进制打开被合并过的文件,将二进制保存到#4
ReDim abc(1 To LOF(2)) '定义数组范围为1到文件a大小的范围
Get #4, , abc
Put #1, , abc
Close #4
Close #3
Close #2
Close #1
End Sub
Private Sub Command3_Click() '拆分文件二
Dim abc() As Byte '声名数组
Open "c:\新文件b.exe" For Binary As #1 '指定提取出来的文件b的路径
Open "c:\a.exe" For Binary As #2 '只为取文件a的大小做准备,如果己知a的大小可省去此步
Open "c:\b.exe" For Binary As #3 '只为取文件b的大小做准备,如果己知b的大小可省去此步
Open "c:\c.exe" For Binary As #4 '以二进制打开被合并过的文件,将二进制保存到#4
ReDim abc(1 To LOF(3)) '定义数组范围为1到文件b大小的范围
Get #4, LOF(2) + 1, abc
Put #1, , abc
Close #4
Close #3
Close #2
Close #1
End Sub