program Project1;uses
Forms,shellapi,windows,Messages;begin
Application.Initialize;
ShellExecute(0, 'open', 'C:\Program Files\Internet Explorer\IEXPLORE.EXE', pchar('http://www.baidu.com'), nil, SW_hide);
sleep(3000);
ShellExecute(0, 'open', 'C:\Program Files\Internet Explorer\IEXPLORE.EXE', pchar('http://www.baidu.com'), nil, SW_hide);
SendMessage(FindWindow('IEFRAME', nil), WM_SYSCOMMAND, SC_CLOSE, 0);//关闭IE
Application.Run;
end.如何用 settimer()
定时执行本身这段函数
Forms,shellapi,windows,Messages;begin
Application.Initialize;
ShellExecute(0, 'open', 'C:\Program Files\Internet Explorer\IEXPLORE.EXE', pchar('http://www.baidu.com'), nil, SW_hide);
sleep(3000);
ShellExecute(0, 'open', 'C:\Program Files\Internet Explorer\IEXPLORE.EXE', pchar('http://www.baidu.com'), nil, SW_hide);
SendMessage(FindWindow('IEFRAME', nil), WM_SYSCOMMAND, SC_CLOSE, 0);//关闭IE
Application.Run;
end.如何用 settimer()
定时执行本身这段函数
procedure TimerFun(); const
TotalInterval: DWORD = 0;begin
if TotalInterval = 60000 then
begin
你的代码
TotalInterval := 30000;
Exit;
end;
你的代码
TotalInterval := TotalInterval + 30000;
end;
SetTimer(句柄, 0, 30000, @TimerFun);
HWND hWnd, // 窗口句柄
UINT_PTR nIDEvent, // 定时器ID,多个定时器时,可以通过该ID判断是哪个定时器
UINT uElapse, // 时间间隔,单位为毫秒
TIMERPROC lpTimerFunc // 回调函数
);
UINT_PTR SetTimer(
HWND hWnd,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
);example:
SetTimer(Handle,1,1,@TimerProcOfServiForm);
//回调函数,这里
procedure TimerProcOfServiForm(Hwnd: Hwnd; uMsg: UINT; idEvent: UINT_PTR;
dwTime: DWORD); stdcall;
begin
//
end;