How to create an auto update function. Dim intLocalVer As Integer Dim b() As Byte Dim intRemoteVer As Integer Dim strRemoteVer As String Dim doUpdate As Boolean'从本地文件中读出当前版本号 Open App.Path & "\version.ini" For Input As #1 intLocalVer = CInt(Input(LOF(1), 1)) Close #1 '从网上获取最新版本号 b() = InetUpdate.OpenURL("http://visualbasic.about.com/library/weekly/remotever.dat", 1) strRemoteVer = "" For t = 0 To UBound(b) strRemoteVer = strRemoteVer + Chr(b(t)) Next intRemoteVer = Int(Val(strRemoteVer) )'如果有新版本 If intRemoteVer > intLocalVer Then If MsgBox("A more recent version of this program exists. Would you like to update it now?", vbYesNo Or vbQuestion) = vbYes Then doUpdate = True Else doUpdate = False End If Else MsgBox "You already have the most recent version of this program." doUpdate = False End If'更新 If doUpdate Then b() = InetUpdate.OpenURL("http://visualbasic.about.com/library/weekly/yours.ocx", 1) Open App.Path & "\temp.ocx" For Binary Access Write As #1 Put #1, , b() Close 1 Kill App.Path & "\yours.ocx" Name App.Path & "\temp.exe" As App.Path & "\yors.exe" '写入新的版本号 Open App.Path & "\version.ini" For Output As #1 Print #1, strRemoteVer Close 1 MsgBox "Update Complete!" End If
用Setup Factory v6.03打包它会自己注册控件
你可用AP函I数判断INF里有没数据更新
仅供参考
这里有个vc的例子:
简单的自动升级程序
http://www.vckbase.com/code/downcode.asp?id=1968
Dim b() As Byte
Dim intRemoteVer As Integer
Dim strRemoteVer As String
Dim doUpdate As Boolean'从本地文件中读出当前版本号
Open App.Path & "\version.ini" For Input As #1
intLocalVer = CInt(Input(LOF(1), 1))
Close #1 '从网上获取最新版本号
b() = InetUpdate.OpenURL("http://visualbasic.about.com/library/weekly/remotever.dat", 1)
strRemoteVer = ""
For t = 0 To UBound(b)
strRemoteVer = strRemoteVer + Chr(b(t))
Next
intRemoteVer = Int(Val(strRemoteVer) )'如果有新版本
If intRemoteVer > intLocalVer Then
If MsgBox("A more recent version of this program exists. Would you like to update it now?", vbYesNo Or vbQuestion) = vbYes Then
doUpdate = True
Else
doUpdate = False
End If
Else
MsgBox "You already have the most recent version of this program."
doUpdate = False
End If'更新
If doUpdate Then
b() = InetUpdate.OpenURL("http://visualbasic.about.com/library/weekly/yours.ocx", 1)
Open App.Path & "\temp.ocx" For Binary Access Write As #1
Put #1, , b()
Close 1
Kill App.Path & "\yours.ocx"
Name App.Path & "\temp.exe" As App.Path & "\yors.exe"
'写入新的版本号
Open App.Path & "\version.ini" For Output As #1
Print #1, strRemoteVer
Close 1
MsgBox "Update Complete!"
End If