| 发表于:2007-01-20 08:14:26 楼主 |
有时网络不是很正常要好长时候长可以找到服务器,有什么办法超过3秒就不执行下面代码?我这段代码是在from_load 的时候调用的 private sub exerefresh() '定义四个临时字符串变量 dim s1 as string dim s2 as string dim s3 as string dim s4 as string on error resume next '将本地应用程序update.exe的全路径名存入 s1 '将本地中介程序fastcopy.exe的全路径名存入 s3 s1 = "tnt " '程序的路径等于三的时候表示某个盘符的根目录,例如 d:\ if len(app.path) > 3 then s1 = app.path + "\ " + trim(app_name) + ".exe " s3 = app.path + "\ " + midexename + ".exe " else s1 = app.path + trim(app_name) + ".exe " s3 = app.path + midexename + ".exe " end if s4 = "tnt " '将本地应用程序update.exe文件的修改时间存入 s4 s4 = filedatetime(s1) s2 = "tnt " '将网络上应用程序update.exe文件的修改时间存入 s2 s2 = filedatetime(exepath + app_name + ".exe ") timer1.enabled = false if s2 = "tnt " then msgbox "没有找到最新的可执行文件: " + exepath + app_name + ".exe " _ + vbcrlf + vbcrlf + "原因1:存放最新exe的服务器或者工作站没有打开; " _ + vbcrlf + "原因2:存放最新exe的路径错误或者exe文件不存在; " _ + vbcrlf + "请将此情况通知程序员. " + vbcrlf + vbcrlf _ + vbcrlf + "按确定按钮后,将继续运行本地exe文件. ", vbcritical, "提示 " end if if s2 = "tnt " or s4 = "tnt " then exit sub '如果网络上应用程序update.exe文件的修改时间,大于本地update.exe文件的修改时间 '然后再运行本地update.exe ,中介程序退出后,整个更新过程结束. if cdate(s2) > cdate(s4) then '将网络上的中介程序fastcopy.exe复制到本地,这样可防止本地无中介程序时无法进行更新 filecopy exepath + midexename + ".exe ", s3 '则运行中介程序fastcopy.exe ,将最新的update.exe 复制到本地 s1 = shell(s3 + " " + exepath + ", " + app_name + ".exe ", vbnormalfocus) '本地应用程序update.exe 终止运行,否则已经更新的update.exe无法覆盖本地的update.exe . end end if end sub |
|
|
|
|