检查指定的网址是否可达!

zmxjh 2002-11-07 06:08:34
怎样确定指定的网址是否为死连接!
例如:
if (Check("http://aaa.bbb.com/index.htm")) then
AfxMessageBox("OK");
else
AfxMessageBox("Error,指定的网址为死连结!");
...全文
110 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
masterz 2002-11-07
  • 打赏
  • 举报
回复
#include <afxinet.h>
#include <stdio.h>
#include <malloc.h>
#include <iostream.h>
#include <io.h>

int main(void)
{
CInternetSession session("My Session");
CHttpFile *file = NULL;

unsigned long code = 0, con_len = 0;
char buff[1000] = "";
long i = 0;
char *file_text = NULL;

printf("getting file\n\n");
file = (CHttpFile*)session.OpenURL("http://stan/default.asp",1, INTERNET_FLAG_TRANSFER_ASCII, NULL,0);

if(file)
{
file->QueryInfoStatusCode(code);
printf("Got It\n\n**status code is : %i**\n\n",code);
}



return 0;
}
check the returned status code, 200-299 Success
wuxuan 2002-11-07
  • 打赏
  • 举报
回复
通过HTTP协议来打开url,如果能打开就表示可达,否则就不可达。

3,056

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC HTML/XML
社区管理员
  • HTML/XML社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧