Solved

Filesize using Wininet but not using ftp protocol

Posted on 2003-10-29
4
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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