🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Connect to a password protected file and download it

#116
From: Colin B Maharaj
Date: Tue, 22 Jul 2008 11:57
82 lines
3554 bytes
Hi Anthony, have you looked at wput?
It is a unix utility that connects to
a ftp server,logs in, and downloads a file.
This can be configured to run at the command
line. There is a windows port as well.

Another one is wget (opposite of wput)

I use it in my application as part of a scheduled
script.
Why tell you this?
Well why write something if it already exists.
and I have not used much FTP yet with Indy.

http://wput.sourceforge.net/


Another thing you can try is the WinINet routines,
remember these relay on Internet explorer....
example....

//--------------------------------------------------------------------------.

void SaveURLToFile(AnsiString UrlName, AnsiString FN)
{
   HINTERNET hSession;
   hSession = InternetOpen("AGENT", INTERNET_OPEN_TYPE_DIRECT, NULL, 
NULL, 0);
   if (hSession)
   {
     HINTERNET hService;
     hService = InternetOpenUrl(hSession, UrlName.c_str(), NULL, 0, 0, 0);
     if (hService)
     {
        DWORD dwBytesAvailable, dwBytesRead=1;
        InternetQueryDataAvailable(hService, &dwBytesAvailable, 0, 0);
        char *lpBuffer = new char [dwBytesAvailable+1];
        int h = FileCreate(FN);
        while (dwBytesRead != 0)
        {
          InternetReadFile(hService, lpBuffer, dwBytesAvailable, 
&dwBytesRead);
          FileWrite(h, lpBuffer, dwBytesRead);
        }
        delete lpBuffer;
        FileClose(h);
     }

   }
   InternetCloseHandle(hSession);
}

//--------------------------------------------------------------------------.




ANTHONY WEST wrote:
> I am using Borland builder 4 standard. I have searched
> the internet for a couple of hours looking for tutorials/source
> code that will download a file from a password protected
> directory on my website. The main purpose is to have my
> app check for updates and download them if available. I
> don't care if the method goes through FTP or HTTP.
> 
> I have a text file on my web server that contains the
> latest version information.
> 
> I would prefer not to use any components because I am
> looking to understand how the code works. I found information
> for the MFC that shows how to do it, but those header files
> naturally will compile with Borland because they do not
> exists.
> 
> Any pointers on how this could be done?
> 
> --
> Anthony West
> <-- What a great day to be alive :) -->
> 
> 
Technical Details
Message-ID: <4885cb46$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <487daabb$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,17413f8a0ec4caed
X-Google-Attributes: gidfeeec,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 22 Jul 2008 07:57:55 -0400
From: Colin B Maharaj <noreply@myhost.com>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.internet.web
Subject: Re: Connect to a password protected file and download it
References: <487daabb$1@newsgroups.borland.com>
In-Reply-To: <487daabb$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Antivirus: avast! (VPS 080722-0, 07/22/2008), Outbound message
X-Antivirus-Status: Clean
NNTP-Posting-Host: 190.58.103.195
Message-ID: <4885cb46$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1216727878 190.58.103.195 (22 Jul 2008 04:57:58 -0700)
Lines: 82
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail