本文整理自网络,侵删。
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, 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'); //200,302未重定位标志
if Assigned(hfile) then
InternetCloseHandle(hfile);
InternetCloseHandle(hsession);
end;
end;
相关阅读 >>
Delphi 双击listbox1内容,数据插入到memo1/synedit1鼠标指定位置
Delphi fmx 从app程序直接跳转到支付宝付款转帐页面
Delphi开发firemonkey应用程序时无法打开窗体的解决
Delphi 判断时间是否合法 -isvaliddatetime、isvaliddate、isvalidtime、isvaliddateday
Delphi xe5实现通过tmemorystream将一个unicodestring写入到一个unicode文本文件
更多相关阅读请进入《Delphi》频道 >>