delphi 判断网络链接文件是否存在


本文整理自网络,侵删。

 function  CheckUrlFileExists(const aURL: string):Boolean;  
//uses WinInet;  
var  
  hSession, hfile: hInternet;  
  dwindex, dwcodelen: dword;  
  dwcode: array[1..20] of Char;  
  res: PChar;  
  url:string;  
begin  
  Result :false;  
  url := aURL;  
  if Pos('http://', LowerCase(url)) = 0 then  
    url :'http://' + url;  
  hSession := InternetOpen('InetURL:/1.0', INTERNET_OPEN_TYPE_PRECONFIG,  nilnil0);  
  if Assigned(hsession) then  
  begin  
    hfile := InternetOpenUrl(hsession, PChar(url), nil0, 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'); //200,302未重定位标志  
    if Assigned(hfile) then  
      InternetCloseHandle(hfile);  
    InternetCloseHandle(hsession);  
  end;  
end

相关阅读 >>

Delphi原生方法取得文件的md5

Delphi upload 上传文件

Delphi dos编程

Delphi tnotification android通知

Delphi 安卓读写ini文件

Delphi通过setupapi.dll列举和停用硬件设备

Delphi二分查找算法(预排序数组的查找)

Delphi 双击关闭pagecontrol中的一个分页

Delphi将dbgrid数据导出到excel表中

Delphi xe增强的rtti妙用--动态创建包中的窗口类

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...