Article View: borland.public.cppbuilder.nativeapi
Article #10611download file from internet
From: ScOe
Date: Wed, 31 Mar 2004 12:07
Date: Wed, 31 Mar 2004 12:07
26 lines
1949 bytes
1949 bytes
How can i download file from adress like
http://server/dir1/dir2/dir3/file.ext
i've use InternetOpen, InternetConnect, HttpOpenRequest, InternetReadFile
but i allways get 0 sized file.
code:
hInternet = InternetOpen("CBZCommander", INTERNET_OPEN_TYPE_DIRECT,
NULL, NULL, INTERNET_FLAG_ASYNC);
Inethandle = InternetConnect(hInternet,"server",
INTERNET_DEFAULT_HTTP_PORT, NULL,
NULL, INTERNET_SERVICE_HTTP, NULL, NULL);
HINTERNET hResource = HttpOpenRequest(Inethandle,
NULL, "dir1/dir2/dir3/file.ext", NULL, NULL, NULL,
INTERNET_FLAG_RELOAD, NULL);
char buf[4096];
DWORD bytesRead, totalRead = 0, BytesWritten;
HANDLE hFile = CreateFile("e:\\temp\\downloaded.tmp", GENERIC_WRITE,
FILE_SHARE_WRITE, NULL,CREATE_NEW, 0, 0);
if(hFile == INVALID_HANDLE_VALUE){
ShowMessage("URLDownloadToFileA: Unable to open file for write: "+
String(GetLastError()));
}
else {
while(InternetReadFile(hResource, &buf, sizeof(buf), &bytesRead)){
...
Technical Details
Message-ID:
<406ab532@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!border1.nntp.ash.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,3762eecd161977b9,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-03-31 04:22:04 PST From: "ScOe" <cbinders@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: download file from internet Date: Wed, 31 Mar 2004 14:07:59 +0200 Lines: 29 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 193.198.130.193 Message-ID: <406ab532@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1080735026 193.198.130.193 (31 Mar 2004 04:10:26 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!border1.nntp.ash.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail