[Delphi]检查URL是否有效的函数
2016-06-13 17:35
567 查看
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;
相关文章推荐
- delphi 文件搜索,遍历所有子目录
- DbgridEh数据导出到Excel的方法(Delphi)--适用Ehlib7.0+D7
- delphi 浮点数float转换成十六进制字符串的方法(FloatToHex)
- delphi中exit,abort,break,continue 的区别
- delphi 浮点数转换成十六进制字符串的方法
- 计算器(delphi)
- 奖学金评分系统(系统分析与设计版与Delphi实现代码)
- 在Delphi中创建线程,请一定使用BeginThread()代替CreateThread()创建线程!
- Delphi中使用比较少的一些语法
- Delphi CRC算法, 不错
- Delphi Modbus RTU CRC16校验码
- 如何使用Delphi编写Modbus RTU CRC16的校验码
- Delphi CRC算法crcexecute
- Delphi CRC32Verify控件
- Delphi CRC16校验算法实现(转)
- delphi crc校验函数
- Delphi_检查exe文件是否是"随机基址"
- Delphi 字符指针分配内存
- delphi IDE RAD 丢失的快捷键 Ctrl+Shift+F
- delphi定时