Article View: borland.public.cppbuilder.nativeapi
Article #8509Re: Downloading a file from FTP-server via API: FtpGetFile( )
From: Bob Gonder
Date: Wed, 20 Oct 2004 02:35
Date: Wed, 20 Oct 2004 02:35
94 lines
4390 bytes
4390 bytes
Oren Halvani wrote:
>- InternetOpen = passed !
>- InternetConnect = failed !
>Instead of using the IP ("83.133.48.22", ) i tried to use the
>host: "ftp.halvani.de" but, it's also not working..
>
>Hans can you explain me how and where to use:
>
>InternetGetLastResponseInfo( )
>
>maybe this could help me further..
Anytime an internet functions fails, check it for the error.
HINTERNET handle_Session = InternetOpen("My App",
if( NULL == handle_Session )
{ FunctionThatReports_InternetGetLastResponseInfo("OpenError");
}else{
handle_Connect = InternetConnect(handle_Session,
if( NULL == handle_Connect )
{FunctionThatReports_InternetGetLastResponseInfo("ConnectError");
}else{
void FunctionThatReports_InternetGetLastResponseInfo(char*where)
{ char lpBuffer[8*1024];
DWORD Err = GetLastError();
DWORD Llp = 8*1024;
if( Err < INTERNET_ERROR_BASE )
{ sprintf( lpBuffer, "Standard Windows Error Number %i", Err);
}else
if( Err == ERROR_INTERNET_EXTENDED_ERROR )
{ InternetGetLastResponseInfo( &Err, lpBuffer, &Llp);
}else
{ sprintf(lpBuffer,"Standard.Internet.Error.Number.%i",Err);
};
MessageBox(hWnd,lpBuffer,where,MB_OK|MB_ICONINFORMATION|MB_TOPMOST);
}
> HINTERNET handle_Session = InternetOpen("My App",
> 0,
> 0,
> NULL,
> INTERNET_FLAG_ASYNC),
Might be wrong, Mine is
if( NULL != (hInternetSession = InternetOpen(
"Microsoft Internet Explorer", // agent
INTERNET_OPEN_TYPE_PROXY, // access
"ftp-gw", // proxy server
NULL, // defaults
0)) ) // synchronous
> handle_Connect = InternetConnect(handle_Session,
> "83.133.48.22",
> INTERNET_DEFAULT_FTP_PORT,
> user.c_str(),
> pass.c_str(),
> INTERNET_SERVICE_FTP,
> 0,
> INTERNET_FLAG_CACHE_ASYNC);
hFTPSession = InternetConnect(
hInternetSession,
"ftp.halvani.de", //make sure this is correct
INTERNET_INVALID_PORT_NUMBER,
name, // make sure this is correct.
pass, // make sure this is the correct password
INTERNET_SERVICE_FTP,
0,
(DWORD)0);
> if(FtpGetFile(handle_Connect, "ftp://ftp.halvani.de/index.php",
>"C:\\down\\index(from_remote).php",
> true, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_ASCII, 0))
You might also want to change your TRUE to FALSE.
bResult = FtpGetFile(
hFTPSession, // Handle from an InternetConnect call
from,to,
FALSE, // always copy
FILE_ATTRIBUTE_NORMAL,
FTP_TRANSFER_TYPE_BINARY, // exact copy
0/*context*/);
Technical Details
Message-ID:
<jshbn0h9h4m4bj9qmglalehv3ikf4k3c4q@4ax.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-mailReferences:
<4175072a$1@newsgroups.borland.com> <417510a8$1@newsgroups.borland.com> <417513d7@newsgroups.borland.com> <417553a0$1@newsgroups.borland.com> <4175559b@newsgroups.borland.com> <41755f35$1@newsgroups.borland.com> <4175bfa3$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8c7cb2fd84899d4c X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Downloading a file from FTP-server via API: FtpGetFile( ) Date: Tue, 19 Oct 2004 19:35:21 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <jshbn0h9h4m4bj9qmglalehv3ikf4k3c4q@4ax.com> References: <4175072a$1@newsgroups.borland.com> <417510a8$1@newsgroups.borland.com> <417513d7@newsgroups.borland.com> <417553a0$1@newsgroups.borland.com> <4175559b@newsgroups.borland.com> <41755f35$1@newsgroups.borland.com> <4175bfa3$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.77.147.118 X-Trace: newsgroups.borland.com 1098239716 67.77.147.118 (19 Oct 2004 19:35:16 -0700) Lines: 97 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