VB 版本检查升级模块
'模块
'模块名称UpdateModule
Function UpdateCheck() '升级检查
Dim NUrl As String
Dim NFile As String
Dim ExeLen As String
Dim ServerUrl as string
ServerUrl = "http://..."
iniPath$ = App.Path & "\Version.ini"
With Form1
entry = .VersionNumber.Caption: r = WritePrivateProfileString("Info", "VersionNumber", entry, iniPath)
entry = .FormName.Caption: r = WritePrivateProfileString("Info", "FormName", entry, iniPath)
entry = .FormCode.Caption: r = WritePrivateProfileString("Info", "FormCode", entry, iniPath)
entry = Format(Date, "yyyy-mm-dd") & " " & Format(Now, "HH:MM:ss"): r = WritePrivateProfileString("Info", "LastRun", entry, iniPath)
End With
If Dir(App.Path & "\Update", vbDirectory) = "" Then
MkDir App.Path & "\Update"
End If
NUrl = ServerUrl & "/programupdate/UpdateSetting.txt"
NFile = App.Path & "\Update\UpdateSetting.ini"
If Dir(NFile) <> "" Then
Kill NFile
End If
Call Form1.Cdf_DownLoad(NUrl, NFile)
If Dir(NFile) <> "" Then
iniPath$ = NFile
Form1.UpdateTemp.Text = GetFromINI("Setting", "Size", iniPath)
End If
If Dir(App.Path & "\Update.exe") <> "" Then
ExeLen = FileLen(App.Path & "\Update.exe")
Else
ExeLen = 0
End If
If clng(ExeLen) = clng(Form1.UpdateTemp.Text) Then '大小一致
Call ShellExecute(0, "open", App.Path & "\Update.exe", 0, 0, 1)
Else '大小不一致
if dir(App.Path & "\Update.exe") <> "" then
Kill App.Path & "\Update.exe"
end if
NUrl = ServerUrl & "/programupdate/Update.rar"
NFile = App.Path & "\Update\Update.rar"
Call Form1.Cdf_DownLoad(NUrl, NFile)
FileCopy App.Path & "\Update\Update.rar", App.Path & "\Update.exe"
Kill App.Path & "\Update\Update.rar"
Call ShellExecute(0, "open", App.Path & "\Update.exe", 0, 0, 1)
End If
End Function
'窗口
'控件
'VersionFrame(frame)
'VersionNumber(label)
'FormName(label)
'FormCode(label)
'UpdateTemp(text)
'调用
'Call UpdateCheck '升级检查