🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #1705

Re: Range check error

#1705
From: Mark Jacobs
Date: Mon, 11 Oct 2004 19:15
48 lines
2920 bytes
I wrote a generic Win32-based function to transfer a file. Here it is :-

unsigned long mjgeturlconts(AnsiString url,AnsiString fnm)
{
  char *bfr; unsigned long nmbyts=0,ba,br=1; FILE *fp;
  HINTERNET
hss=InternetOpen("WhateverApp",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
  if (!hss) { ShowMessage("Could not Open Internet Session"); return 0;}
  HINTERNET hsv=InternetOpenUrl(hss,url.c_str(),NULL,0,0,0);
  if (!hsv) { ShowMessage("Could not Open Service "+url);
InternetCloseHandle(hss); return 0;}
  InternetQueryDataAvailable(hsv,&ba,0,0);
  if (ba==0) { ShowMessage("No Data Available at "+url);
InternetCloseHandle(hss); return 0;}
  bfr=(char *)malloc((ba+9)*sizeof(char));
  if (!bfr) { ShowMessage("Not Enough Memory - "+mjfmtnm(ba+9));
InternetCloseHandle(hss); return 0;}
  fp=fopen(fnm.c_str(),"wb");
  if (!fp)
  {
    ShowMessage("Could not Open File "+fnm+"\n"+mjgetlasterror());
    free(bfr); InternetCloseHandle(hss); return 0;
  }
  while (br!=0) { InternetReadFile(hsv,bfr,ba,&br);
fwrite(bfr,sizeof(char),br,fp); nmbyts+=br;}
  fclose(fp); InternetCloseHandle(hss); hss=NULL; free(bfr);
  return nmbyts;
}

-- 
Mark Jacobs

"RS" <rs.reloaded@wanadoo.fr> wrote in message
news:416990f7$1@newsgroups.borland.com...
| The real source.cpp contains the good syntax :
| NMFTP1->Download("file.exe","c:\\temp\\file.exe");
|
| No, the problem is that the NMFTP does not "finish" the download, but the
| file "file.exe" is correctly transfered.
|
|   NMFTP1->Download("file.exe","c:\\temp\\file.exe");
|   ShowMessage("Download Complete");
|   NMFTP1->Disconnect();
|
| ShowMessage("Download Complete") does not appear, but the file is correctly
| transfered into the local directory c:\temp,
| and my application is blocked because this "NMFTP download" does not finish
| correctly.
Technical Details
Message-ID: <416adbbe@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41698024@newsgroups.borland.com> <416985d3$1@newsgroups.borland.com> <416990f7$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,6ec3ebc859553701
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Mark Jacobs" <http://www.jacobsm.com/mjmsg.htm?Borland%20Newsgroup>
Newsgroups: borland.public.cppbuilder.internet.web
References: <41698024@newsgroups.borland.com> <416985d3$1@newsgroups.borland.com> <416990f7$1@newsgroups.borland.com>
Subject: Re: Range check error
Date: Mon, 11 Oct 2004 20:15:08 +0100
Lines: 49
Organization: DK Computing
MIME-Version: 1.0
Content-Type: text/plain;
 charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 81.86.186.94
Message-ID: <416adbbe@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1097522110 81.86.186.94 (11 Oct 2004 12:15:10 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail