Hiya, I am trying to use the following code found on EE but I cannot get it to work and it is hopefully something simple I have messed up!
The FileSize retrieved does not seem to be accurate, for example I tried to get the size of http://www.google.co.uk/search?hl=en&safe=off&q=test&meta=
but it said it was 1359176 bytes?? am i missing something here?
dwSize, Reserved: DWORD;
hSession := InternetOpen( 'MyApp', INTERNET_OPEN_TYPE_PRECONF
IG, nil, nil, 0 );
if Assigned( hSession ) then
hService := InternetOpenUrl(hSession, PChar(edit1.text), nil, 0, 0, 0);
if Assigned( hService ) then
dwSize := sizeof(FileSize); //what does this do? FileSize isn't anything yet is it??
Reserved := 0;
HttpQueryInfo(hService, HTTP_QUERY_CONTENT_LENGTH or HTTP_QUERY_FLAG_NUMBER,
@FileSize, dwSize, Reserved); //get the size
buf := Format('FileSize:%d', [FileSize]); //convert to a string
form1.Memo1.Lines.Add( buf ); //add the size to TMemo
InternetCloseHandle( hService );
InternetCloseHandle( hSession );
Thanks for any help, it's driving me mad, trying to avoid Indy which I was using previously as this seems to be faster.