想写一段小程序可以每隔一小时自动检查网页是否可用

来源:百度知道 编辑:UC知道 时间:2024/05/05 12:12:52
希望能给出非常详细的方法,不要光只是代码的

另外该网页ping不通,想用返回正确代码的方法得知该网页是否正常,谢谢了

给你一段Delphi代码,直接在项目文件中写就可以了,我曾在Delphi7中用过,可以测试网络是否连通。

uses
Windows,
WinInet;

var
lpszURL: LPTSTR;
// dwFlags: DWORD;
begin
{ TODO -oUser -cConsole Main : Insert code here }
lpszURL := 'http://www.126.com';
// InternetCheckConnection(lpszURL, 1, 0);

if InternetCheckConnection(lpszURL, 1, 0) then
MessageBox(0, '可以连接', '连接检测', 0)
else
MessageBox(0, '不能连接', '连接检测', 0);
end.