VB怎么实现更新程序wstr = Inet1.OpenURL("")
If wstr"" And wstr"v1.0" Then
a = MsgBox("你好,检查到远程有升级程序,是否更新?", vbOKCancel, "提示")
If a = 1 Then '确定更新
DownFile
End If
ElseIf wstr = "" Or wstr = "v1.0" Then
MsgBox "当前此版本为最新程序,若有建议请联系QQ:121734199", vbOKOnly, "提示"
End If
Private Sub DownFile()
If ii = 0 Then
strURL = "小说.exe"
mstrFileName = App.Path"\小说_v1.0.exe"
ElseIf ii = 1 Then
strURL = "更名器.exe"
mstrFileName = App.Path"\更名器.exe"
Else
Shell App.Path"\更名器.exe", vbHide
End
End If
mblnPutStart = False
With Winsock1
If .StatesckClosed Then .Close
.Protocol = sckTCPProtocol
.RemoteHost = Split(Replace(strURL, "http://", ""), "/")(0)
.RemotePort = 80
.Connect
End With
End Sub
Private Sub Winsock1_Connect()
Dim s As String
s = "GET " + strURL + " HTTP/1.0" + vbCrLf
s = s + "Accept: */*" + vbCrLf
s = s"Pragma: no-cache"vbCrLf
s = s"Cache-Control: no-cache"vbCrLf
s = s"Connection: close"vbCrLfvbCrLf
s = s + vbCrLf
Winsock1.SendData s
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim RevData() As Byte
Dim a() As Byte, b() As String, c() As String
Dim s As String, i As Long, k As Long
On Error GoTo fail
If mblnPutStart = False Then
Winsock1.PeekData RevData, vbArray Or vbByte
k = InStrB(1, RevData, ChrB(13)ChrB(10)ChrB(13)ChrB(10))
If k0 Then
Winsock1.GetData RevData, vbArray Or vbByte
a = LeftB(RevData, k - 1)
RevData = https://www.04ip.com/post/MidB(RevData, k + 4)
s = StrConv(a, vbUnicode)
b = Split(s, vbCrLf)
If InStr(1, b(0), "200 OK", vbTextCompare) = 0 Then GoTo fail
For i = 1 To UBound(b)
c = Split(b(i), ": ")
Select Case c(0)
Case "Content-Length"
mlngFileLen = CLng(c(1))
End Select
Next
mblnPutStart = True
mlngCurByte = UBound(RevData) + 1
mlngFileNum = FreeFile
Open mstrFileName For Binary As #mlngFileNum
Else
Exit Sub
End If
Else
Winsock1.GetData RevData, vbArray Or vbByte
mlngCurByte = mlngCurByte + bytesTotal
End If
Put #mlngFileNum, , RevData
Label3.Caption = "已下载字节:"mlngCurByte"/"mlngFileLen
If mlngCurByte = mlngFileLen Then
Close #mlngFileNum
ii = ii + 1
DownFile
End If
Exit Sub
fail:
MsgBox "网络传输错误,文件下载失败!"
End Sub
visual basic 2008里怎么添加fso对象?vb6.0知道,2008不懂啊~添加 Imports System.IO 就可以读写vb.netpeek了 。
Dim line As String
Dim sr As StreamReader = New StreamReader(strPath,System.Text.Encoding.Default)
Do While sr.Peek() 0
line = sr.ReadLine()
Loop
sr.Close()
sr = Nothing
高分VB6.0的问题 远程高手进VB网络编程--WinSock控件及WinSockAPI
WinSock简介
Socket(套接字)最初是由加利福尼亚大学Berkeley(伯克利)分校为UNIX操作系统开发的网络通信接口,随着UNIX的广泛使用,Socket成为当前最流行的网络通信应用程序接口之一 。20世纪90年代初 , 由Sun Microsystems,JSB,FTP software,Microdyne和Microsoft等几家公司共同定制了一套标准,即Windows Socket规范 , 简称WinSock 。
VB编写网络程序主要有两种方式:1.winsock控件 2.winsockAPI
二,WinSock控件的使用
1.WinSock控件的主要属性
a.Protocol属性
通过Protocol属性可以设置WinSock控件连接远程计算机使用的协议 。可选的协议是TCP和UDP对应的VB的常量分别是sckTCPProtocol和sckUDPProtocol,Winsock控件默认协议是TCP 。注意:虽然可以在运行时设置协议,但必须在连接未建立或断开连接后 。
推荐阅读
- 电脑怎么玩侏罗纪世界端游,电脑怎么玩侏罗纪世界端游手机版
- 怎么退出校园路由器账号,校园wifi怎么退出
- 游戏开发独立,独立游戏开发
- vb.net读取cvs vbs 读取文件
- ios16锁屏壁纸绿色,苹果屏保壁纸绿色
- 62位cpu什么概念,cpu32位和62位的区别
- phpredis缓存技术,php redis缓存分页数据
- java窗口大小控制代码 java窗口缩放
- 现在asp.net用什么框架,aspnet