检查一个URL是否有效 检查一个URL是否有效 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 检查一个URL是否有效 这个函数将会检查URL是否有效。唯一的先决条件就是你必须在线。 URL前可能有 http:// 前缀,却省情况也是 http:// 作前缀,函数 internetOpenUrl 对 FTP:// 和 gopher:// 前缀均提供支持。 例子中我检查返回代码是否为 '200' 和 '302'(重定位标记),你也可以按你的需要修改返回码. 仅修改 the result := 表达式 这句即可. uses wininet; Function CheckUrl(url:string):boolean; var hSession, hfile, hRequest: hInternet; dwindex,dwcodelen :dword; dwcode:array[1..20] of char; res : pchar; begin if pos('http://',lowercase(url))=0 then url := 'http://'+url; Result := false; hSession := InternetOpen('InetURL:/1.0', INTERNET_OPEN_TYPE_PRECONFIG,nil, nil, 0); if assigned(hsession) then begin hfile := InternetOpenUrl( hsession, pchar(url), nil, 0, INTERNET_FLAG_RELOAD, 0); dwIndex := 0; dwCodeLen := 10; HttpQueryInfo(hfile, HTTP_QUERY_STATUS_CODE, @dwcode, dwcodeLen, dwIndex); res := pchar(@dwcode); result:= (res ='200') or (res ='302'); if assigned(hfile) then InternetCloseHandle(hfile); InternetCloseHandle(hsession); end; end; 在RxRichEdit里面添加图片,怎么改变添加图片的大小呢? 求一个自动访问网站的示例代码 解决立即给分 ★★要过年了,派点利市★★ 有没有实时地将Line in的语音经过处理(提高频率),然后播放出来的例子? 一个有关字符串处理的问题,急,请高手赐教!!!! ord问题! ado访问access的问题 请问怎样取得SQL SERVER服务器的名称? 简单问题!如何在程序中调用系统的浏览器连接到指定的网站?? delphi clientdataset 赋值 多绑定lookup 引起全局卡 请问如何判断"http://..."地址是否存在? 怎样终止外部程序
这个函数将会检查URL是否有效。唯一的先决条件就是你必须在线。 URL前可能有 http:// 前缀,却省情况也是 http:// 作前缀,函数 internetOpenUrl 对 FTP:// 和 gopher:// 前缀均提供支持。 例子中我检查返回代码是否为 '200' 和 '302'(重定位标记),你也可以按你的需要修改返回码. 仅修改 the result := 表达式 这句即可. uses wininet; Function CheckUrl(url:string):boolean; var hSession, hfile, hRequest: hInternet; dwindex,dwcodelen :dword; dwcode:array[1..20] of char; res : pchar; begin if pos('http://',lowercase(url))=0 then url := 'http://'+url; Result := false; hSession := InternetOpen('InetURL:/1.0', INTERNET_OPEN_TYPE_PRECONFIG,nil, nil, 0); if assigned(hsession) then begin hfile := InternetOpenUrl( hsession, pchar(url), nil, 0, INTERNET_FLAG_RELOAD, 0); dwIndex := 0; dwCodeLen := 10; HttpQueryInfo(hfile, HTTP_QUERY_STATUS_CODE, @dwcode, dwcodeLen, dwIndex); res := pchar(@dwcode); result:= (res ='200') or (res ='302'); if assigned(hfile) then InternetCloseHandle(hfile); InternetCloseHandle(hsession); end; end;