TIEDownload
NewsProductsDownloadsSupportForumCredits

TEmbeddedWB 
History 
HtmlEdit 
TIEAddress 
TIEDownload 
TIEDownloadManager 
IEGuid 
TIEParser 
Favorites 
TIESecurityManager 
IE5Tools 
TIETravelLog 
TLinksBar 
Protocols 
TRichEditWB 
TWebUpdater 
ResourceTool 
UI - lessParser 
Delphi Links 
[Home][Support][TIEDownload]

 

EventspropertiesOptions


TIEDownload :

  IEDownload

Easy-to-use component for asynchronous or synchronous download using Url Moniker and implementing: 

IBindStatusCallback 
IHttpNegotiate 
IHttpAuthenticate 
IHttpSecurity 
IWindowforBindingUI

Download files

Upload files

Resume broken download (if supported by server)

Supported methods: put, post, get and custom

Asynchronous (non-blocking) or Synchronous (blocking)

... and a lot more

 

This component is still work-in-progress. Multipart and much more not yet supported. Feel free to add your enhancements and co-work on further development.


Quick start:

Drop IEDownload component on a form. Use

     IEDownload1.Go('http://www.euromind.com/iedelphi')

to download to a stream, or

     IEDownload1.Go('http://www.euromind.com/iedelphi','c:\iedelphi.htm')

to download to a file.


Use OnBeginningTransaction to add additionally headers to the transaction.

Use OnResponse to get response headers and eventually add additional requestheaders.

Use OnAuthenticate to add Password and Username if needed.

Capture the progress in the OnProgress event.

Use the OnData event to get the data for parsing/editing 'on the fly'.

Use OnComplete to get the result of the download and all data in a TStream. You can also use GetBindInfo (Ibinding), QueryOptions (IWinInetInfo) or QueryInfo (IWinItetHttpInfo) to get whatever information you need about the resource.  

User agent:
Here you can set your application User_Agent string that will be send to the server.
The string will be auto added on load, and auto remove on destroy


Options:

ASYNCHRONOUS
Value that indicates that the moniker should return immediately from
IMoniker::BindToStorage or IMoniker::BindToObject. The actual result of the bind to an object or the bind to storage arrives asynchronously. The client is notified through calls to its IBindStatusCallback::OnDataAvailable or IBindStatusCallback::OnObjectAvailable method. If the client does not specify this flag, the bind operation will be synchronous, and the client will not receive any data from the bind operation until the IMoniker::BindToStorage or IMoniker::BindToObject call returns.

Value that indicates the client application calling the IMoniker::BindToStorage method prefers that the storage and stream objects returned in IBindStatusCallback::OnDataAvailable return E_PENDING when they reference data not yet available through their read methods, rather than blocking until the data becomes available. This flag applies only to BINDF_ASYNCHRONOUS operations. Note that asynchronous stream objects return E_PENDING while data is still downloading and return S_FALSE for the end of the file.

NOPROGRESSIVERENDERING
Value that indicates that progressive rendering should not be allowed.

OFFLINEOPERATION
Value that indicates that the moniker should be bound to the cached version of the resource.

GETNEWESTVERSION
Value that indicates the bind operation should retrieve the newest version of the data/object possible. For URL monikers, this flag maps to the Microsoft Win32 Internet (WinInet) flag,
INTERNET_FLAG_RELOAD, which forces a download of the requested resource.


NOWRITECACHE
Value that indicates the bind operation should not store retrieved data in the disk cache. BINDF_PULLDATA must also be specified to turn off the cache file generation when using the IMoniker::BindToStorage method.
 

NEEDFILE
Value that indicates the downloaded resource must be saved in the cache or a local file.
 

PULLDATA
Value that indicates the asynchronous moniker allows the client of IMoniker::BindToStorage to drive the bind operation by pulling the data, rather than having the moniker drive the operation by pushing the data to the client. When this flag is specified, new data is only read/downloaded after the client finishes downloading all data that is currently available. This means data is only downloaded for the client after the client does an
IStream::Read operation that blocks or returns E_PENDING. When the client specifies this flag, it must be sure to read all the data it can, even data that is not necessarily available yet. When this flag is not specified, the moniker continues downloading data and calls the client with IBindStatusCallback::OnDataAvailable whenever new data is available. This flag applies only to BINDF_ASYNCHRONOUS bind operations.
 
GNORESECURITYPROBLEM
Value that indicates that security problems related to bad certificates and redirects between HTTP and Secure Hypertext Transfer Protocol (HTTPS) servers should be ignored. For URL monikers, this flag corresponds to the WinInet flags
INTERNET_FLAG_IGNORE_CERT_CN_INVALID, INTERNET_FLAG_IGNORE_CERT_DATE_INVALID, INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP, and INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS.
Security Alert  Using this value incorrectly can compromise the security of your application. If your implementation of IBindStatusCallback::GetBindInfo indicates that security problems with certificates and redirection should be ignored, users may be susceptible to unwanted information disclosure. You should not implement IBindStatusCallback::GetBindInfo such that it returns BINDF_IGNORESECURITYPROBLEM because it prevents Microsoft Internet Explorer from notifying users of security concerns. For more information, see Security Considerations: URL Monikers.

RESYNCHRONIZE
Value that indicates the resource should be resynchronized. For URL monikers, this flag maps to the WinInet flag, INTERNET_FLAG_RESYNCHRONIZE, which reloads an HTTP resource if the resource has been modified since the last time it was downloaded. All File Transfer Protocol (FTP) and Gopher resources are reloaded.
 
HYPERLINK
Value that indicates hyperlinks are allowed.
 
 
NO_UI
Value that indicates that the bind operation should not display any user interfaces.
 
 
SILENTOPERATION
Value that indicates the bind operation should be completed silently. No user interface or user notification should occur.
 
 
PRAGMA_NO_CACHE
Value that indicates that the resource should not be stored in the Internet cache.
 
 
GETCLASSOBJECT
Value that indicates that the class object should be retrieved. Normally the class instance is retrieved.

RESERVED_1
Reserved.
 

FREE_THREADED
Reserved.

 
DIRECT_READ
Value that indicates that the client application does not need to know the exact size of the data available, so the information is read directly from the source.

FORMS_SUBMIT
Value that indicates that this transaction should be handled as a forms submittal.

GETFROMCACHE_IF_NET_FAIL

Value that indicates the resource should be retrieved from the cache if the attempt to download the resource from the network fails.
 

FROMURLMON

Value that indicates the binding is from a URL moniker. This value was added for Internet Explorer 5.

FWD_BACK
Value that indicates that the moniker should bind to the copy of the resource that is currently in the Internet cache. If the requested item is not found in the Internet cache, the system will attempt to locate the resource on the network. This value maps to the Win32 Internet application programming interface (API) flag, INTERNET_FLAG_USE_CACHED_COPY.
 

PREFERDEFAULTHANDLER
Urlmon.dll searches for temporary or permanent namespace handlers before it uses the default registered handler for particular protocols. This value changes this behavior by allowing the moniker client to specify that Urlmon.dll should look for and use the default system protocol first.

RESERVED_2
Reserved.

RESERVED_3
Reserved.

To take full advance of the many features in IEDownload it is recommended to read:
Url Moniker
IBindStatusCallback Interface
IHttpSecurity Interface
IAuthenticate Interface
IHttpNegotiate Interface
Q176787 - HOWTO- Get WinInet Information from a URL Moniker Binding
Q165800 - PostMon.exe Demonstrates How to Use URL Moniker to POST Data

Q156905 - SAMPLE- Progress Uses IAuthenticate to Bind to Secured Web Page
IWinInetInfo--QueryOption Method

IWinInetHttpInfo--QueryInfo Method

Range- Demonstrate Http Read Range

IEDownload has only four main procedure:
procedure Go(Url: string); overload;
procedure Go(Url, Fname: string); overload;
procedure Cancel(Item: TBSCB); overload;
procedure Cancel; overload;


To start download you just say:

IEDownload1.Go(Url);

and to abort the download:

IEDownload1.Cancel;


In the following code 3 urls are downloaded.

If Asynchronous and AsyncStorage are selcted in Options IEDownload will download them asynchronous (non-blocking). They will all be downloaded simultaneously, and you don't know which one will finish first.

If you choose to download synchronous (Asynchronous disabled in Options) IEDownload wil start downloading the first URL and finish it before downloading the next.

In this code a memo field display the data as they arrive:


var

Links : TStringlist;

procedure
TForm1.Button1Click(Sender: TObject);
var
x : integer;
begin
Links:=TStringlist.create;
Links.add('http://www.borland.com');
Links.add('http://www.inprise.com');
Links.add('http://www.microsoft.com');
For x:=0 to Links.count-1 do IEdownload1.Go(Links[x]);
end;

procedure TForm1.IEDownload1Data(Sender: TBSCB; var Buffer: PByte;
var BufLength: Cardinal);
begin
memo1.lines.add(Pchar(Buffer));
end;

If they are downloaded synchronous the memo will display the source from the first URL then continue with the source from the next.

If downloaded asynchronous the source will be completely mixed up, depending on what server is fast enought to deliver some data.

To keep track of what data belongs to what URL you need to use the Sender parameter, which is available in all eventhandlers. 

Sender.Url contains the url to which the data belong.

So if you want to download the 3 urls asynchronous and display the source in three different memoboxes the OnData code should be changes to the following:

procedure TForm1.IEDownload1Data(Sender: TBSCB; var Buffer: PByte;
var BufLength: Cardinal);
begin
case Links.IndexOf(Sender.Url) of
0: memo1.lines.add(PChar(Buffer));
1: memo2.lines.add(PChar(Buffer));
2: memo3.lines.add(PChar(Buffer));
end;
end;

You can always cancel the download of a specific URL by using IEDownload1.Cancel(Sender).

IEDownload1.Cancel  without any parameter will cancel all ongoing downloads.

If you want to add a progressbar to each of the three download, you will also have to use the Sender.URL:

function TForm1.IEDownload1Progress(Sender: TBSCB; ulProgress,
ulProgressMax, ulStatusCode: Cardinal; szStatusText: PWideChar): HRESULT;

begin

   case Links.IndexOf(Sender.Url) of
       0:
          begin
          progressbar1.Max := ulProgressMax;
          progressbar1.Position := ulProgress;
          end;
        1:
          begin
            
progressbar2.Max := ulProgressMax;
          progressbar2.Position := ulProgress;
          end;
        2:
          begin
           
progressbar3.Max := ulProgressMax;
          progressbar3.Position := ulProgress;
         
end;
    end;
end;

You can use a few more methods in Sender:

Sender.QueryInfo
Sender.QueryOptions
Sender.GetBindResult

For information about the great amount of information you can get from these methods, see: 

IWinInetInfo--QueryOption Method
IWinInetHttpInfo--QueryInfo Method

IBinding--GetBindResult Method

Using Method Post and PostData:

The following code shows how to use the post method:

procedure TForm1.Button1Click(Sender: TObject);
begin
(*
Following line is default and not needed unless you
have changed AdditionalHeader
*)
IEDownload1.AdditionlaHeader.add(
'Content-Type: application/x-www-form-urlencoded');

IEDownload1.Method:=Post;
IEDownload1.PostData:='firstname=Per&lastname=Larsen';
IEDownload1.Go('http://localhost/postmon.asp');
end;

[Previous][Up][Next]

Created  by
Per Lindsų Larsen

Copyright (c) 2005 bsalsa productions. All rights reserved.

bsalsa@bsalsa.no-ip.info