本文整理自网络,侵删。
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 xe7 的 android bitmap转jpg图的参数问题
Delphi kbmmw sampleservice/sampleclient方式传输数据集
Delphi controlcount和componentcount的区别
Delphi 结束360safe和360保险箱进程 for Delphi
更多相关阅读请进入《Delphi》频道 >>