Using Win32 functions in Visual FoxPro Image Gallery
Internet Functions (WinInet)
..msdn
CreateMD5SSOHash
DeleteUrlCacheEntry
DetectAutoProxyUrl
FindCloseUrlCache
FindFirstUrlCacheEntry
FindFirstUrlCacheGroup
FindNextUrlCacheEntry
FindNextUrlCacheGroup
FtpCommand
FtpCreateDirectory
FtpDeleteFile
FtpFindFirstFile
FtpGetCurrentDirectory
FtpGetFile
FtpGetFileSize
FtpOpenFile
FtpPutFile
FtpRemoveDirectory
FtpRenameFile
FtpSetCurrentDirectory
GetUrlCacheEntryInfo
HttpOpenRequest
HttpQueryInfo
HttpSendRequest
InternetAttemptConnect
InternetAutodial
InternetAutodialHangup
InternetCanonicalizeUrl
InternetCheckConnection
InternetCloseHandle
InternetConnect
InternetCrackUrl
InternetDial
InternetFindNextFile
InternetGetConnectedState
InternetGetConnectedStateEx
InternetGetCookie
InternetGetLastResponseInfo
InternetGoOnline
InternetOpen
InternetOpenUrl
InternetQueryDataAvailable
InternetQueryOption
InternetReadFile
InternetSetCookie
InternetSetFilePointer
InternetTimeFromSystemTime
InternetTimeToSystemTime
InternetWriteFile
Code examples:
Creating a directory on the FTP
Custom FTP Class for Visual FoxPro application
Custom HttpRequest class (WinINet)
Deleting a file stored on the FTP server
Downloading files from the FTP server using InternetReadFile
How to download a file from the FTP server using FtpGetFile
How to download this reference`s archive through WinInet functions using InternetOpenUrl
How to upload a local file to FTP server using FtpPutFile
Opening access to the Microsoft Internet functions for the application
Reading Internet Query options
Reading list of folders and files on FTP server
Removing FTP directory
Retrieving list of files on the FTP directory
Retrieving size of a remote file
Uploading file to the FTP server using InternetWriteFile
Using FtpCommand
Using InternetSetFilePointer when resuming interrupted download from the Internet
Reading Internet Query options

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
 
#DEFINE INTERNET_INVALID_PORT_NUMBER  0 
#DEFINE INTERNET_OPEN_TYPE_DIRECT     1 
#DEFINE INTERNET_SERVICE_FTP          1 
#DEFINE FTP_TRANSFER_TYPE_ASCII       1 
#DEFINE FTP_TRANSFER_TYPE_BINARY      2 
 
#DEFINE INTERNET_OPTION_CONNECT_TIMEOUT     2
#DEFINE INTERNET_OPTION_RECEIVE_TIMEOUT     6
#DEFINE INTERNET_OPTION_SEND_TIMEOUT        5
#DEFINE INTERNET_OPTION_USERNAME            28
#DEFINE INTERNET_OPTION_PASSWORD            29
#DEFINE INTERNET_OPTION_VERSION             40
#DEFINE INTERNET_OPTION_PROXY_USERNAME      43
#DEFINE INTERNET_OPTION_PROXY_PASSWORD      44
#DEFINE INTERNET_OPTION_CONNECTED_STATE     50
#DEFINE INTERNET_OPTION_CLIENT_CERT_CONTEXT 84
    DO decl
 
    PRIVATE hOpen, hFtpSession
    STORE 0 TO hOpen, hFtpSession
 
    IF connect2ftp("ftp.linux.com", "anonymous",;
            "vfp"+LEFT(SYS(3),5)+"@win32.com") 
        ? GetFtpStatus (hFtpSession)
        ? GetUserData (hFtpSession)
        = InternetCloseHandle (hFtpSession)  
        = InternetCloseHandle (hOpen) 
    ENDIF 
* end of main
 
FUNCTION GetFtpStatus(hConnection)
    LOCAL lcBuffer, lnBufsize
    lcBuffer = " "
    lnBufsize = 0
    IF ReadOption(hConnection, INTERNET_OPTION_CONNECTED_STATE,;
        @lcBuffer, @lnBufsize)
        RETURN (LEFT(lcBuffer,1) = Chr(1))
    ENDIF
RETURN .F.
 
FUNCTION GetUserData(hConnection)
    LOCAL lcBuffer, lnBufsize, lcResult
 
    lnBufsize = 64
    lcBuffer = " "
    = ReadOption(hConnection, INTERNET_OPTION_USERNAME,;
        @lcBuffer, @lnBufsize)
    lcResult = LEFT(lcBuffer, lnBufsize)
 
    lnBufsize = 64
    lcBuffer = " "
    = ReadOption(hConnection, INTERNET_OPTION_PASSWORD,;
        @lcBuffer, @lnBufsize)
    lcResult = lcResult + ", " + LEFT(lcBuffer, lnBufsize)
RETURN  lcResult
 
FUNCTION ReadOption(hConnection, lnOption, lcBuffer, lnBufsize)
    LOCAL lnResult
    IF TYPE("lnBufsize")<>"N" Or lnBufsize<=0
    * this call determines the buffer size needed
        = InternetQueryOption(0, lnOption, @lcBuffer, @lnBufsize)
    ENDIF
 
    * read the option
    lcBuffer = REPLI (Chr(0), lnBufsize)
RETURN InternetQueryOption(hConnection, lnOption, @lcBuffer, @lnBufsize) = 1
 
FUNCTION connect2ftp(strHost, strUser, strPwd) 
    * open access to Inet functions  
    hOpen = InternetOpen ("vfp", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0)  
 
    IF hOpen = 0  
        ? "Unable to get access to WinInet.Dll" 
        RETURN .F. 
    ENDIF 
 
    * connect to FTP  
    hFtpSession = InternetConnect (hOpen, strHost, INTERNET_INVALID_PORT_NUMBER,;  
        strUser, strPwd, INTERNET_SERVICE_FTP, 0, 0)  
 
    IF hFtpSession = 0  
    * close access to Inet functions and exit  
        = InternetCloseHandle (hOpen)  
        ? "FTP " + strHost + " is not available" 
        RETURN .F. 
    ELSE
        ? "Connected to " + strHost + " as: [" + strUser + ", *****]"  
    ENDIF  
RETURN .T. 
 
PROCEDURE  decl
    DECLARE INTEGER InternetCloseHandle IN wininet INTEGER hInet
 
    DECLARE INTEGER InternetQueryOption IN wininet;
        INTEGER hInternet, INTEGER lOption,;
        STRING @sBuffer, INTEGER @lBufferLength
 
    DECLARE INTEGER InternetOpen IN wininet;
        STRING sAgent, INTEGER lAccessType, STRING sProxyName,;
        STRING sProxyBypass, STRING lFlags
 
    DECLARE INTEGER InternetConnect IN wininet;
        INTEGER hInternetSession, STRING sServerName,;
        INTEGER nServerPort, STRING sUsername,;
        STRING sPassword, INTEGER lService,;
        INTEGER lFlags, INTEGER lContext
 
RETURN
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
3330 bytes  
Created: 2001-07-24 12:00:00  
Modified: 2008-10-03 15:25:57  
Visits in 7 days: 78  
Listed functions:
InternetCloseHandle
InternetConnect
InternetOpen
InternetQueryOption
Printer friendly API declarations
My comment:
Here you can reach complete list of Internet Option Flags as long as presented link stays valid. The MSDN is known for its volatile links.

The testing of FTP status appears to be useful when you have connected to the FTP some time ago and want to validate the connection before exchanging data or sending commands.

INTERNET_OPTION_CLIENT_CERT_CONTEXT
This flag is not supported by InternetQueryOption. The lpBuffer parameter must be a pointer to a CERT CONTEXT structure and not a pointer to a CERT CONTEXT pointer.

If an application receives ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED, it must call InternetErrorDlg or use InternetSetOption to supply a certificate before retrying the request. CertDuplicateCertificateContext is then called so that the certificate context passed can be independently released by the application.

* * *
There is an article of Ayhan AVCI
Connecting to a HTTPS server with SSL using Wininet, sending client certificate and reading response,
which I have found recently at the Code Project. Though based on VB code it may still save your time.

#kwd: sln_http.
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.242.188.217)
1.91 hrs.Function: 'GetIpNetTable'
Function group: 'IP Helper'
2.31 hrs.Example: 'Mapping and disconnecting network drives'
 Example: 'How to print FoxPro form'
2.43 hrs.Example: 'Storing screen shot of a form to bitmap file'
 Function: 'GetModuleFileName'
4.09 hrs.Example: 'Displaying standard progress dialog box when copying files'
 Example: 'Printing Image File, programmatically set print page orientation to landscape'
5.72 hrs.Function: 'MAPIFindNext'
Function group: 'Simple MAPI'
10.83 hrs.Example: 'Configuring DEVMODE structure for a printer'
 Example: 'Enumerating ports that are available for printing on a specified server'
Google
Advertise here!