다음을 통해 공유


Accessing the FTP Protocol (Windows CE 5.0)

Send Feedback

To access the FTP protocol programmatically, you can use WinInet to perform the following tasks:

  • Navigating directories
  • Enumerating, creating, removing, and renaming directories
  • Renaming, uploading, downloading, and deleting files

You can also use the default Windows FTP client, or other third-party clients to access an FTP server from a desktop computer.

To access an FTP server programmatically using WinInet

  1. Call InternetOpen to initialize an Internet handle.

    InternetOpen creates the root HINTERNET handle that is used to establish the FTP session. The HINTERNET handle is used by all subsequent functions.

  2. Call InternetConnect to create an FTP session.

    When calling InternetConnect, specify INTERNET_DEFAULT_FTP_PORT for the nServerPort parameter and INTERNET_SERVICE_FTP for the dwService parameter.

    This function uses the handle returned by InternetOpen to create a specific FTP session. InternetConnect initializes an FTP session for the specified site by using the arguments passed to it and creates HINTERNET. This is a branch off of the root handle. In the case of an FTP session, InternetConnect attempts to establish a connection to the specified site.

  3. Call FtpGetFile or FtpFindFirstFile.

    InternetConnect returns a handle, such as FtpGetFile or FtpFindFirstFile, that subsequent functions can use.

    Use the InternetFindNextFile function with FtpFindFirstFile to find the next file in a file search by using the search parameters and HINTERNET handle from FtpFindFirstFile.

    To complete a file search, continue to call InternetFindNextFile using the HINTERNET handle returned by FtpFindFirstFile until the function fails with the extended error message ERROR_NO_MORE_FILES. To get the extended error data, call the GetLastError function.

  4. Call InternetCloseHandle to close the FTP session created by calling InternetConnect.

  5. Call InternetCloseHandle to close the handle created by calling InternetOpen.

    Note   Applications must specify a directory relative to the current directory or include the full directory path.

See Also

FTP Server Application Development | FTP WinInet Functions | About HINTERNET Handles | FTP Sessions

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.