随手写的一个大概:
var
hSession, hConnect, hRequest: hInternet;
HostName, FileName: string;
AAgent: string;
Buf: Pointer;
dwBufLen, dwIndex: DWord;
RequestMethod: PChar;
InternetFlag: DWord;
AcceptType: LPStr;
procedure CloseHandles;
begin
InternetCloseHandle(hRequest);
InternetCloseHandle(hConnect);
InternetCloseHandle(hSession);
end;
begin
try
ParseURL(FURL, HostName, FileName);
hSession := InternetOpen(nil,INTERNET_OPEN_TYPE_PRECONFIG, nil,nil,0);//没有使用代理
hConnect := InternetConnect(hSession, PChar(HostName), INTERNET_DEFAULT_HTTP_PORT,
nil,nil, INTERNET_SERVICE_HTTP, 0, 0);//这里可能需要用户名和密码
RequestMethod := 'GET'
InternetFlag := INTERNET_FLAG_RELOAD;
AcceptType := PChar('Accept: ' + '*/*');
hRequest := HttpOpenRequest(hConnect, RequestMethod, PChar(FileName), 'HTTP/1.0',
PChar(FReferer), @AcceptType, InternetFlag, 0);
HttpSendRequest(hRequest, nil, 0, nil, 0)
dwIndex := 0;
dwBuflen := 1024;
GetMem(Buf, dwBuflen);
FResult := HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH, Buf, dwBuflen, dwIndex);
if FResult then FFileSize := StrToInt(StrPas(Buf));//这里就是文件大小了
{...比较文件的大小...}
FreeMem(Buf);
CloseHandles;
except
end;