我正在尝试使用 Stubs 进行试验,我看到的所有教程都告诉你要这样获取 Stub.exe:
FileOpen(1, Application.StartupPath & "\sub.exe", OpenMode.Binary, OpenAccess.Read)
这是后来的解释:
FileOpen(Reference number, file name including the path, mode to open the file as, Mode Of Access)
我试图从我的项目中的资源输入存根,但是当我将它添加到该行时(它看起来像这样:)
FileOpen(1, My.Resources.Stub, OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
然后它用红色强调它并说:
“一维字节数组”类型的值无法转换为“字符串”。
我相信这想说的是 .exe 不能放入字符串中?如我错了请纠正我...
我的完整代码如下:
Public Class Form1
Const FileSplit As String = "|split|"
Dim stub, text1, button As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sfd As New SaveFileDialog
sfd.Filter = "Executables(.exe)|*.exe"
If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
text1 = TextBox1.Text
button = TextBox2.Text
Else
Exit Sub
End If
FileOpen(1, My.Resources.Stub, OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
stub = Space(LOF(1))
FileGet(1, stub)
FileClose(1)
FileOpen(1, sfd.FileName, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
FilePut(1, stub & FileSplit & text1 & FileSplit & button)
FileClose(1)
MsgBox("Success")
End Sub
End Class