1:打开VB-外接程序-外接程序管理器-VB6资源编辑器,将“在启动中加载”和“加载/卸载”都打勾;
2:在“工具”菜单中打开“资源编辑器”后选择“自定义资源-选择你的b.exe文件”,然后点击保存!
A程序代码:
Private Sub Command1_Click()
Dim bytdata() As Byte
intFile = FreeFile()
bytdata = LoadResData(101, "CUSTOM") '101 为资源号,custom为资源类型
strtmpfile = "b.exe" '临时文件的路径与文件名
Open strtmpfile For Binary Access Write As #intFile
Put #intFile, , bytdata
Close (intFile)
Call Shell("b.exe", 1)
End Sub
'打包运行文件
'在资源管理器里倒数第二个按钮添加自定义文件资源,加入以下过程
Public Function SaveFileFromRes(vntresourceId As Variant, sTYPE As String, sfilename As String) As Boolean
Dim bytimage() As Byte
Dim ifilenum As Integer
On Error GoTo SaveFileFromRes_err
SaveFileFromRes = True
bytimage = LoadResData(vntresourceId, sTYPE)
ifilenum = FreeFile
Open sfilename For Binary As ifilenum
Put #ifilenum, , bytimage
Close ifilenum
SaveFileFromRes_err: Exit Function
SaveFileFromRes = False: Exit Function
End Function
'调用
SaveFileFromRes 101, "CUSTOM", "test.exe" '释放路径自己添加
Shell "test.exe", 1 '释放后运行
filecopy b程序路径,C:\逼程序
shell b程序