Solved

Filesize using Wininet but not using ftp protocol

Posted on 2003-10-29
4
218 Views
Last Modified: 2010-04-05
Hi.

Question same as in title. Need to find out what is the file size (in bytes) that is placed on web server. Is it possible when working with wininet ??

Thank you in advance
0
Comment
Question by:Murdoc
  • 2
  • 2
4 Comments
 

Author Comment

by:Murdoc
ID: 9644890
..i forgot to tell you that i do not want to use wininet ftp protocol   :)
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9647502
I think that if you do a HEAD, you can check the content-length...
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 100 total points
ID: 9647539
better yet, you can do it like this with HttpQueryInfo:

var
  hSession: HINTERNET;
  hService: HINTERNET;
  FileSize: Longint;
  dwSize, Reserved: DWORD;
  buf: String;
begin
  hSession := InternetOpen( 'MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0 );
  if Assigned( hSession ) then
  begin
    hService := InternetOpenUrl(hSession, PChar(sURL), nil, 0, 0, 0);
    if Assigned( hService ) then
    begin
      dwSize := sizeof(FileSize);
      Reserved := 0;
      HttpQueryInfo(hService, HTTP_QUERY_CONTENT_LENGTH or HTTP_QUERY_FLAG_NUMBER,
                    @FileSize, dwSize, Reserved);
      buf := Format('FileSize:%d', [FileSize]);
      Memo1.Lines.Add( buf );
    end;
    InternetCloseHandle( hService );
  end;
  InternetCloseHandle( hSession );
end;
0
 

Author Comment

by:Murdoc
ID: 9648579
Thanks a lot Eddie.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now