Date: 02-16-2022
Return to Index
created by gbSnippets
'Summary of layers for Internet connection. WinInet is the layer in Windows that
'interfaces directly with the client application.
'Client Side Server Side
'WinInet --> SMTP --> WinSock --> Tcp --> IP IP <-- Tcp <-- WinSock <-- SMTP <-- WinInet
' FTP UDP UDP FTP
' HTTP HTTP
'The WinInet DLL that is distributed with Windows provides the ability to create
'HTTP, HTTPS, and FTP connections to the Internet - providing 100+ API that
'can be used to manage the sessions. Fortunately, from that large API base,
'there is a much smaller list of API which provide basic Internet access.
'From that large WinInetAPI base, there are several that form the core of accessing files:
InternetAttemptConnect '- checks to see If connection already exists.
InternetCheckConnection '- checks connection (pings designated server)
InternetCanonicalizeURL '- converts
InternetOpen '- sets connection characteristics (creates Root Handle)
InternetConnect '- create HTTP/FTP session (creates branch handle off Root Handle) (w/FTP, also attempts to connect to URL)
InternetOpenURL '- opens a resource specified by a complete FTP or HTTP URL.
FtpOpenFile '- accesses a specified FTP URL
FtpGetFile '- retrieves a file from the FTP server and stores it as a local file
HttpOpenRequest '- create an HTTP request handle
InternetReadFile - '- reads data from a handle opened by the InternetOpenUrl, FtpOpenFile, or HttpOpenRequest function.
InternetCloseHandle '- close a single handle
'For general file access, the InternetOpenURL/InternetReadFile API combination can download
'a file asynchronously and store it on the local PC - while also providing download status information.
'The pair work with both FTP and HTTP URLs.
'Full information on WinInet can be found on MSDN at:
http://msdn.microsoft.com/en-us/library/aa385331%28VS.85%29.aspx
'API Arguments
InternetAttemptConnect 'returns 0=success, all else=fail
DWord dwReserved
InternetCheckConnection 'returns T/F
LPCTSTR lpszUrl,
DWord dwFlags,
DWord dwReserved
InternetCanonicalizeUrl 'returns T/F
LPCTSTR lpszUrl,
LPTSTR lpszBuffer,
LPDWord lpdwBufferLength,
DWord dwFlags
InternetOpen 'returns handle for subsequent API calls
LPCTSTR lpszAgent, gbSnippets
DWord dwAccessType, Internet_open_type_direct, Internet_open_type_proxy, Internet_open_type_Preconfig
LPCTSTR lpszProxyName,
LPCTSTR lpszProxyBypass,
DWord dwFlags
'Note: If use Internet_open_type_direct Set lpszProxyName = Null, lpszProxyBypass = Null
InternetConnect 'returns handle to session
HINTERNET hInternet,
LPCTSTR lpszServerName,
INTERNET_PORT nServerPort,
LPCTSTR lpszUsername,
LPCTSTR lpszPassword,
DWord dwService,
DWord dwFlags,
DWord_PTR dwContext
InternetOpenUrl 'returns handle to the URL
HINTERNET hInternet,
LPCTSTR lpszUrl,
LPCTSTR lpszHeaders,
DWord dwHeadersLength,
DWord dwFlags,
DWord_PTR dwContext
InternetReadFile 'returns T/F
HINTERNET hFile,
LPVOID lpBuffer,
DWord dwNumberOfBytesToRead,
LPDWord lpdwNumberOfBytesRead
FtpGetFile 'returns T/F
HINTERNET hConnect,
LPCTSTR lpszRemoteFile,
LPCTSTR lpszNewFile,
BOOL fFailIfExists,
DWord dwFlagsAndAttributes,
DWord dwFlags,
DWord_PTR dwContext
HINTERNET HttpOpenRequest
HINTERNET hConnect,
LPCTSTR lpszVerb,
LPCTSTR lpszObjectName,
LPCTSTR lpszVersion,
LPCTSTR lpszReferer,
LPCTSTR *lplpszAcceptTypes,
DWord dwFlags,
DWord_PTR dwContext
InternetCloseHandle 'returns T/F
HINTERNET hInternet
'gbs_00361
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm