找回密码
 加入
搜索
查看: 3655|回复: 2

[网络通信] _IECreate()有时读的本地缓存的,怎么让它强制读网络?

[复制链接]
发表于 2013-3-1 19:58:45 | 显示全部楼层 |阅读模式
我的机子主板有点问题,每次只要一断电,Cmos都会回到默认的,系统时间也会回到出厂日期
CMOS我没有招,好象在Windows系统下不能修改CMOS参数。于是就只想把时间改回来。
于是有下面的代码:若有联网就读网络时间更正本地时间,若没有,就用上次启动本程序时记下的时间。

但实际应用中,我发现个问题:用 _IECreate()后,用_IEBodyReadText()得到数据,有时居然不是实时网上的,应该读的IE缓存,我把ie的临时文件,cookie等删除后又可以读网络上的了。

请问,这该怎么办?想用InetRead()函数的,但它无法获得:http://www.timedate.cn/worldclock/ti.asp 这个网页的时间。怎么强制读取网页内容?或者用什么别的方式可以代替


#include <IE.au3>
#include <Date.au3>

Global $iFlag = 0, $sUrl, $oIE, $sTime, $aTime
RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "TimeCorrect", "REG_SZ", @ScriptFullPath)
Do
        If Ping('www.baidu.com', 2000) Then ExitLoop
        $iFlag += 1
Until $iFlag == 10

$sUrl = "http://www.timedate.cn/worldclock/ti.asp"
$oIE = _IECreate($sUrl, 0, 0)
If @error Then
        $sTime = IniRead(@ScriptDir & '\time.ini', 'Main', 'OldTime', _NowCalc())
        $aTime = StringRegExp($sTime, '\d+', 3)
Else
        $sTime = _IEBodyReadText($oIE)
        If @error Then $sTime = IniRead(@ScriptDir & '\time.ini', 'Main', 'OldTime', _NowCalc())        
        $aTime = StringRegExp($sTime, '\d+', 3)
EndIf        
If Not IsArray($aTime) Then Exit
_SetDate($aTime[2], $aTime[1], $aTime[0])
_SetTime($aTime[3], $aTime[4], $aTime[5])
IniWrite(@ScriptDir & '\time.ini', 'Main', 'OldTime', _NowCalc())
Exit
发表于 2013-3-1 20:23:37 | 显示全部楼层
$sUrl = "http://www.timedate.cn/worldclock/ti.asp"
$xmlhttp=ObjCreate("msxml2.xmlhttp")
With $xmlhttp
        .open("get",$sUrl,true)
        .send
        While .readystate<>4
                Sleep(50)
        WEnd
        $str=.responsetext
EndWith
$aTime = StringRegExp($str, '\=(\d+)', 3)
If Not IsArray($aTime) Then Exit
MsgBox(0,"",StringFormat("%d-%d-%d %02d:%02d:%02d",$aTime[0],$aTime[1],$aTime[2],$aTime[4],$aTime[5],$aTime[6]))
这个试下
发表于 2013-3-1 21:04:39 | 显示全部楼层
顶贴,InetRead()函数
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-1 10:11 , Processed in 0.073980 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表