Newsgroups : Microsoft : microsoft.public.inetsdk.programming.wininet : 2006 Aug : What is the difference between InternetConnect handle and InternetConnectURL han
| Subject: | What is the difference between InternetConnect handle and InternetConnectURL han |
| Posted by: | "Paulaner" () |
| Date: | Mon, 14 Aug 2006 10:54:25 |
I have become confused about what type of handle I get back from
various winInet calls. My goal is to open a URL and retrieve files
using ftp.
If I use InternetConnect, then I can call FtpFindFirstFile,
InternetFindNextFile and FtpGetFile to do all the work. But, the
InternetConnect requires specific server, dir, and port parameters,
and does not take a URL like "ftp://servername/subdir:port" .
So, I decided to use InternetConnectURL because this routine will
accept the ftp URL instead of requiring me to parse the url into
separate components (server, port, etc) as needed by InternetConnect.
Well, apparently InternetConnectURL returns a different handle than
InternetConnect?!? Note, I am using the INTERNET_FLAG_RAW_DATA flag.
When I use the handle returned from InternetConnectURL, I cannot call
FtpFindFirstFile. This results in an
ERROR_INTERNET_INCORRECT_HANDLE_TYPE error. Instead, I can use
InternetFindNextFile to enumerate the list of files. That works
fine, retrieving the files on the server in a WIN32_FIND_DATA
structure. But now, if I try to download one of these files, I
cannot use this same handle for FtpGetFile, it too gives the
ERROR_INTERNET_INCORRECT_HANDLE_TYPE. Ugh.
So, is it true that if I want to use FtpGetFile, I cannot use
InternetConnectURL? Is there something simple I'm missing?
PS: I'm coding this in VC6.0 for W2K & XP systems.