program Refresh;
{$APPTYPE CONSOLE}
uses
SysUtils,
Messages,
WinProcs;
var
IsFirstRun,ErrorOccur:Boolean;
const UrlKanXue='C:\Program Files\Internet Explorer\IEXPLORE.EXE http://bbs.pediy.com/';
const SleepTime=360000;//360000;//6分钟
begin
try
{ TODO -oUser -cConsole Main : Insert code here }
while not ErrorOccur do
begin
if not IsFirstRun then
begin
IsFirstRun:=True;
if WinExec(PAnsiChar(UrlKanXue),SW_NORMAL)>31 then //第一次运行时先访问主页,登陆一下。
begin
Writeln(FormatDateTime('hh:mm:ss',GetTime)+' 成功访问主页');
Sleep(SleepTime);
SendMessage(FindWindow('IEFrame','看雪软件安全论坛 - www.pediy.com - Windows Internet Explorer'),WM_CLOSE,0,0);
end
else
ErrorOccur:=True;
end
else
begin
if WinExec(PAnsiChar(UrlKanXue),SW_HIDE)>31 then
begin
Writeln(FormatDateTime('hh:mm:ss',GetTime)+' 成功刷新页面');
Sleep(SleepTime);
SendMessage(FindWindow('IEFrame','看雪软件安全论坛 - www.pediy.com - Windows Internet Explorer'),WM_CLOSE,0,0);
end
else
ErrorOccur:=True;
end
end;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.