Article View: borland.public.cppbuilder.internet.web
Article #1456Re: download file
From: Colin B Maharaj
Date: Sat, 18 Dec 2004 22:45
Date: Sat, 18 Dec 2004 22:45
44 lines
2370 bytes
2370 bytes
Francisco navarro wrote:
> I have one tcppbrowser component and I want to download one file from a web
> page ( http://www.myyweb.com).
> How can I do it ?
>
>
Try this.....Using a Button, a Memo and the URL in an Edit. Also the
include is needed...
#include "WININET.h"
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HINTERNET hSession;
AnsiString URLData = "";
hSession = InternetOpen("MyApp", INTERNET_OPEN_TYPE_DIRECT, NULL,
NULL, 0);
if (hSession)
{
HINTERNET hService;
hService = InternetOpenUrl(hSession, Edit1->Text.c_str(), NULL, 0,
0, 0);
if (hService)
{
DWORD dwBytesAvailable, dwBytesRead=1;
InternetQueryDataAvailable(hService, &dwBytesAvailable, 0, 0);
char *lpBuffer = new char [dwBytesAvailable+1];
while (dwBytesRead != 0)
{
InternetReadFile(hService, lpBuffer, dwBytesAvailable,
&dwBytesRead);
lpBuffer[dwBytesRead]=NULL;
URLData += lpBuffer;
}
delete lpBuffer;
Memo1->Text = URLData;
}
}
InternetCloseHandle(hSession);
}
Technical Details
Message-ID:
<41c4b303$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!feeder1.cambrium.nl!217.19.17.162.MISMATCH!textnews.cambrium.nl!217.19.16.137.MISMATCH!feeder2.cambrium.nl!feed.tweaknews.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41bdd497@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,4bfba8af7cfdac27 X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Sat, 18 Dec 2004 18:45:26 -0400 From: Colin B Maharaj <noreply@myhost.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7a) Gecko/20040219 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.internet.web Subject: Re: download file References: <41bdd497@newsgroups.borland.com> In-Reply-To: <41bdd497@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 200.108.12.234 Message-ID: <41c4b303$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1103409923 200.108.12.234 (18 Dec 2004 14:45:23 -0800) Lines: 44 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!feeder1.cambrium.nl!217.19.17.162.MISMATCH!textnews.cambrium.nl!217.19.16.137.MISMATCH!feeder2.cambrium.nl!feed.tweaknews.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail