VB6自动版本更新处理,实例源码
2006-09-14 12:39
656 查看
方法为: 建立两个exe文件,每一个为外壳exe带参数调用另一个存储在服务器数据库的exe文件,客户每次启动应用程序时查验版本下到本机再执行.
外壳带参数exe,先联到数据库,下载完新版exe后,再传递三个参数(用户名,密码,服务器名)给另一个exe文件运行
Private Sub QdCommand_Click() '确定进入系统
On Error GoTo ErrorHandle
Dim sAp As New addPassword '取加密类
Dim RetVal
Dim Res As New ADODB.Recordset
Dim Rs As New ADODB.Recordset
Dim VerNo
Dim strInput As String
If Trim(Text1) = "" Then
Text1.SetFocus
GoTo PROC_EXIT
End If
If Trim(Text2) = "" Then
Text2.SetFocus
GoTo PROC_EXIT
End If
If Trim(Combo1) = "" Then
Combo1.SetFocus
GoTo PROC_EXIT
End If
sServerName = Trim(Combo1)
Me.MousePointer = vbHourglass
If bDatebaseConnect = False Then
If ServerConnect = False Then
MsgBox "数据库联接错误,请查看联机帮助文件 !!! ", vbCritical, "错误"
End
End If
End If
If Trim(Text1) = "administrator" Then GoTo Go '特殊用户
DBOpen Res, "select * from users where f002='" & Trim(Text1) & "'"
If Res.EOF = False Or Res.BOF = False Then
If Trim(Res.Fields("f004")) = sAp.DigestStrToHexStr(Res.Fields(0) & Trim(Text2)) Then '用ID号&密码再MD5加密
GoTo Lo
End If
End If
If iCount >= 3 Then End
Label3 = "用户或密码有误,请重新输入!!!"
Text1 = ""
Text2 = ""
Text1.SetFocus
iCount = iCount + 1
GoTo PROC_EXIT
Lo:
sUserID = Trim(Text1)
sUserPWD = Trim(Text2)
' sServerName '服务器名称
sUserName = IIf(IsNull(Res.Fields("f003")), "", Res.Fields("f003"))
Go:
If Trim(Text2) = "FangKe" Then
sUserID = "administrator"
sUserName = "系统开发用户"
End If
''''较验此用户是否重复登陆
' Dim strS As String '定义返回变量
' Dim AdoComm As New ADODB.Command 'Command对象定义了将对数据源执行的指定命令
' Dim ReturnValue As Integer '调用存储过程的返回值
' Dim mRst As ADODB.Recordset 'Recordset 对象表示的是来自基本表或命令执行结果的记录全集
'
' Set AdoComm.ActiveConnection = Cn
' AdoComm.CommandText = "usertable" '设置Command对象源
' AdoComm.CommandType = adCmdStoredProc '通知提供者CommandText属性有什么
' AdoComm.Parameters(1) = sUserID '输入参数
' AdoComm.Parameters(2) = "2" '输出参数,OutputParameters可以为任意的字符串或数字
' AdoComm.Execute
' ReturnValue = AdoComm.Parameters(0) '存储过程的返回值,返回0则成功执行
' strS = AdoComm.Parameters(2) '把存储过程的输出参数的值赋给变量strS'
' If strS = 1 Then
' MsgBox "此用户名在使用中,请换用户名重新登录!!!", vbCritical
' GoTo PROC_EXIT
' End If
strInput = sUserID & "|" & sUserPWD & "|" & sServerName '传递三个参数给另一exe文件运行
DBOpen Res, "select getdate()"
Date = Res(0) '设定取服务器日期
'更新app.ini文件中的服务器名称
IniWriteKey App.Path & "/app.ini", "database", "ServerName", UCase(sServerName)
'''版本较验
DBOpen Rs, "select * from ver where f001=(select max(f001) from ver)"
If Rs.BOF Or Rs.EOF Then
GoTo SS '数据库中无记录,直接取当前执行文件
End If
If Exists(App.Path & "/" & Rs.Fields("f002") & "1") = True Then Kill App.Path & "/" & Rs.Fields("f002") & "1"
If Exists(App.Path & "/" & Rs.Fields("f002")) = False Then
DownFile:
If Exists(App.Path & "/" & Rs.Fields("f002")) = True Then
Name App.Path & "/" & Rs.Fields("f002") As App.Path & "/" & Rs.Fields("f002") & "1"
End If
SaveToFile App.Path & "/" & Rs.Fields("f002"), "F004"
End If
If Exists(App.Path & "/" & Rs.Fields("f002")) = False Then
MsgBox "数据库中文件有错误,请查对数据库 !!!", vbCritical, "系统错误"
GoTo PROC_EXIT
End If
VerNo = DisplayVerInfo(App.Path & "/" & Rs.Fields("f002"))
If Len(VerNo) > 0 Then
If Trim(VerNo) < Trim(Rs.Fields("f003")) Then
GoTo DownFile
End If
End If
SS: '数据库中无记录,直接取当前执行文件
RetVal = Shell(App.Path & "/" & Rs.Fields("f002") & " " & strInput, 1)
Set Cn = Nothing
Set Res = Nothing
Set Rs = Nothing
Me.MousePointer = flexDefault
End
PROC_EXIT:
Me.MousePointer = flexDefault
Set Res = Nothing
Set Rs = Nothing
Exit Sub
ErrorHandle:
Call ShowError(Me.Name, "Command_Click", Err.Number, Err.Description, "Y")
End Sub
外壳带参数exe,先联到数据库,下载完新版exe后,再传递三个参数(用户名,密码,服务器名)给另一个exe文件运行
Private Sub QdCommand_Click() '确定进入系统
On Error GoTo ErrorHandle
Dim sAp As New addPassword '取加密类
Dim RetVal
Dim Res As New ADODB.Recordset
Dim Rs As New ADODB.Recordset
Dim VerNo
Dim strInput As String
If Trim(Text1) = "" Then
Text1.SetFocus
GoTo PROC_EXIT
End If
If Trim(Text2) = "" Then
Text2.SetFocus
GoTo PROC_EXIT
End If
If Trim(Combo1) = "" Then
Combo1.SetFocus
GoTo PROC_EXIT
End If
sServerName = Trim(Combo1)
Me.MousePointer = vbHourglass
If bDatebaseConnect = False Then
If ServerConnect = False Then
MsgBox "数据库联接错误,请查看联机帮助文件 !!! ", vbCritical, "错误"
End
End If
End If
If Trim(Text1) = "administrator" Then GoTo Go '特殊用户
DBOpen Res, "select * from users where f002='" & Trim(Text1) & "'"
If Res.EOF = False Or Res.BOF = False Then
If Trim(Res.Fields("f004")) = sAp.DigestStrToHexStr(Res.Fields(0) & Trim(Text2)) Then '用ID号&密码再MD5加密
GoTo Lo
End If
End If
If iCount >= 3 Then End
Label3 = "用户或密码有误,请重新输入!!!"
Text1 = ""
Text2 = ""
Text1.SetFocus
iCount = iCount + 1
GoTo PROC_EXIT
Lo:
sUserID = Trim(Text1)
sUserPWD = Trim(Text2)
' sServerName '服务器名称
sUserName = IIf(IsNull(Res.Fields("f003")), "", Res.Fields("f003"))
Go:
If Trim(Text2) = "FangKe" Then
sUserID = "administrator"
sUserName = "系统开发用户"
End If
''''较验此用户是否重复登陆
' Dim strS As String '定义返回变量
' Dim AdoComm As New ADODB.Command 'Command对象定义了将对数据源执行的指定命令
' Dim ReturnValue As Integer '调用存储过程的返回值
' Dim mRst As ADODB.Recordset 'Recordset 对象表示的是来自基本表或命令执行结果的记录全集
'
' Set AdoComm.ActiveConnection = Cn
' AdoComm.CommandText = "usertable" '设置Command对象源
' AdoComm.CommandType = adCmdStoredProc '通知提供者CommandText属性有什么
' AdoComm.Parameters(1) = sUserID '输入参数
' AdoComm.Parameters(2) = "2" '输出参数,OutputParameters可以为任意的字符串或数字
' AdoComm.Execute
' ReturnValue = AdoComm.Parameters(0) '存储过程的返回值,返回0则成功执行
' strS = AdoComm.Parameters(2) '把存储过程的输出参数的值赋给变量strS'
' If strS = 1 Then
' MsgBox "此用户名在使用中,请换用户名重新登录!!!", vbCritical
' GoTo PROC_EXIT
' End If
strInput = sUserID & "|" & sUserPWD & "|" & sServerName '传递三个参数给另一exe文件运行
DBOpen Res, "select getdate()"
Date = Res(0) '设定取服务器日期
'更新app.ini文件中的服务器名称
IniWriteKey App.Path & "/app.ini", "database", "ServerName", UCase(sServerName)
'''版本较验
DBOpen Rs, "select * from ver where f001=(select max(f001) from ver)"
If Rs.BOF Or Rs.EOF Then
GoTo SS '数据库中无记录,直接取当前执行文件
End If
If Exists(App.Path & "/" & Rs.Fields("f002") & "1") = True Then Kill App.Path & "/" & Rs.Fields("f002") & "1"
If Exists(App.Path & "/" & Rs.Fields("f002")) = False Then
DownFile:
If Exists(App.Path & "/" & Rs.Fields("f002")) = True Then
Name App.Path & "/" & Rs.Fields("f002") As App.Path & "/" & Rs.Fields("f002") & "1"
End If
SaveToFile App.Path & "/" & Rs.Fields("f002"), "F004"
End If
If Exists(App.Path & "/" & Rs.Fields("f002")) = False Then
MsgBox "数据库中文件有错误,请查对数据库 !!!", vbCritical, "系统错误"
GoTo PROC_EXIT
End If
VerNo = DisplayVerInfo(App.Path & "/" & Rs.Fields("f002"))
If Len(VerNo) > 0 Then
If Trim(VerNo) < Trim(Rs.Fields("f003")) Then
GoTo DownFile
End If
End If
SS: '数据库中无记录,直接取当前执行文件
RetVal = Shell(App.Path & "/" & Rs.Fields("f002") & " " & strInput, 1)
Set Cn = Nothing
Set Res = Nothing
Set Rs = Nothing
Me.MousePointer = flexDefault
End
PROC_EXIT:
Me.MousePointer = flexDefault
Set Res = Nothing
Set Rs = Nothing
Exit Sub
ErrorHandle:
Call ShowError(Me.Name, "Command_Click", Err.Number, Err.Description, "Y")
End Sub
相关文章推荐
- VB6 IDE 函数过程错误处理代码自动添加的插件(含源码)
- 版本自动更新程序及3种实现策略程序下载(附源码)
- 【代码片-1】 jQuery源码学习(版本1.11)-事件处理-实例函数
- Android程序自动更新功能模块的实现方法【附完整demo源码下载】
- 关于android客户端在线版本更新的总结(json源码)
- “此版本的 SQL Server 不支持用户实例登录标志。该连接将关闭”的处理
- android sdk 安装问题 没有其它版本的自动更新的选项
- Android实现App版本自动更新
- 为程序添加版本自动更新功能(转+详细分析)
- tacker源码分析(Pike版本)--实例化VNF
- R语言软件版本自动更新
- Mac 关闭chrome的自动更新解决版本更新造成的自动化测试脚本执行不通过的问题
- 部分NLuke版本源码更新(2009-11-1)
- 非常实用的小功能 Android应用版本的更新实例
- IONIC 自动更新APP版本
- Android应用更新之自动检测版本及自动升级
- android的APP自动更新程序,检测版本,然后下载安装,但app安装后不提示“完成,打开”?
- git 远程版本库,github提供服务原理,git自动更新发送邮件
- Silverlight实用窍门系列:24.Silverlight多线程技术BackgroundWorker的应用,更新ProgressBar控件【附带源码实例】