WinInet Library (Windows Internet Services)


Frank Russo - February 2007

This is intended to be a simple word set for WinInet.dll in W32Forth.  


Import to DLL

5 PROC InternetOpen - This function initializes an application's use of the WinInet functions.

 

8 PROC InternetConnect – This function opens an FTP or HTTP session for a specified site.

 

2 PROC FtpSetCurrentDirectory - This function changes to a different working directory on the FTP server.

 

3 PROC FtpGetCurrentDirectory - This function retrieves the current directory for the specified FTP session.

 

7 PROC FtpGetFile - This function retrieves a file from the FTP server and stores it under the specified file name, creating a new local file in the process.

 

5 Proc FtpPutFile - This function stores a file on the FTP server.

 

5 PROC FtpOpenFile - This function initiates access to a remote file for writing or reading.

 

6 PROC FtpCommand - This function issues an arbitrary FTP command to the FTP server.

 

1 PROC InternetAttemptConnect -This function attempts to make a connection to the Internet.

 

4 PROC InternetWriteFile - This function writes data to an open Internet file.

 

3 PROC InternetGetLastResponseInfo - This function retrieves the last WinInet function error description or server response on the thread calling this function.

 

1 PROC InternetCloseHandle - This function closes a single Internet handle or a subtree of Internet handles.

 


Initialization & Setup Words

: Inet-Open ( ZStr1 --- Flag)  \ ZStr1 = Zero terminated string with a Caller Name

: Inet-error \ Displays message and error #

: Inet-Connect ( ZSrt1 ZStr2 ZStr3 --- )  \ window handle is loaded to inet-connect-handle or 0 if failed
                        ZStr1 = Server-Name / ZStr2 = UserName / ZStr3 = UserPassword

: Inet-Directory ( ZSrt1 -- ) \ Get current directory of server store in ZStr1

: Change-Inet-Directory  ( ZSrt1 -- ) \ Change working Directory of server to directory found in ZStr1


FTP Words

: FTP-Put-File ( --- Flag) – Fully Implemented see example below for details

: FTP-Get-File ( --- Flag) – Fully Implemented see example below for details

*********************************************************************************
\ Actions this word performs:
\ depth > 5  \ Stack must have 6 parameter passed
\ call InternetOpen
\ call InternetConnect
\ call FtpSetCurrentDirectory - Optional - used if not working in the root directory
\ call FtpPutFile or FtpGetFile
\ call InternetCloseHandle
*********************************************************************************

: FTP-OpenFile ( See Wininet.f for details) – No interface – Yet.

: FTP-WriteFile ( See Wininet.f for details)


Examples:

*********************************************************************************
\ Try 3 times to see if an Internet connection is available
\ If a High Speed connection is not available
\ then Windows will attempted to make a dial-up connection
3 0 do 0 call InternetAttemptConnect  \ Attempt to make an internet connection
0= if 1 to inet-stat leave then       \ Active internet connection found
500 _ms \ delay .5 seconds
Loop
*********************************************************************************
\
\ Set local directory where local file is to be found
dir-path 1024 0 fill current-dir$     \ get current local drive path
zcount dir-path swap cmove             \ and save
 
ftpservice ldir zcount
if $current-dir! drop  \ Set new path for local file to upload
else drop
then
 
\ All data needed by the FTP calls is now stored in a data structure FTPService
 
FTP-Put-File (--- Flag) or FTP-Get-File ( --- Flag)
\    Flag = 0 Failure to upload or download
\    Flag > 1 Success
dir-path $current-dir! drop \ Restore local drive path
;
 
\
\ Caller MUST Load the FTPService data structure with values
\
 FTPService
 dup ftp-size 0 fill
 dup fname s" File name to put or get (<32 characters)" swap cmove
 dup rdir s" Remote directory (<32 characters)" swap cmove    \ null if using default
 dup ldir s" Local Directory (<32 characters)" swap cmove     \ null if using default
 dup username s" Your User Name (<32 characters)" swap cmove
 dup password s" XXXXXXXX (<32 characters)" swap cmove
 dup FTPserver s" ftp-site.com (<64 characters)" swap cmove
 sessionID s" ANY name here is fine (<16 characters)" swap cmove
\
 
 
 



 
 
 
 

Complete

Listing of WinInet Functions

 

Programming element

Description

CommitUrlCacheEntry

This function stores data in the specified file in the Internet cache and associates it with the given Uniform Resource Locator (URL).

CreateUrlCacheEntry

This function creates a local file name for saving the cache entry based on the specified URL and the file extension.

CreateUrlCacheGroup

This function generates cache group identifications.

DeleteUrlCacheEntry

This function removes the file associated with the source name from the cache, if the file exists.

DeleteUrlCacheGroup

This function releases the specified GROUPID and any associated state in the cache index file.

FindCloseUrlCache

This function closes the specified cache enumeration handle.

FindFirstUrlCacheEntry

This function begins the enumeration of the Internet cache.

FindFirstUrlCacheEntryEx

This function begins a filtered enumeration of the Internet cache.

FindFirstUrlCacheGroup

This function initiates the enumeration of the cache groups in the Internet cache.

FindNextUrlCacheEntry

This function retrieves the next entry in the Internet cache.

FindNextUrlCacheEntryEx

This function finds the next cache entry in a cache enumeration started by the FindFirstUrlCacheEntryEx function.

FindNextUrlCacheGroup

Retrieves the next cache group in a cache group enumeration started by FindFirstUrlCacheGroup.

FtpCommand

This function issues an arbitrary FTP command to the FTP server.

FtpCreateDirectory

This function creates a new directory on the FTP server.

FtpDeleteFile

This function deletes a file stored on the FTP server.

FtpFindFirstFile

This function searches the specified directory of the specified FTP session.

FtpGetCurrentDirectory

This function retrieves the current directory for the specified FTP session.

FtpGetFile

This function retrieves a file from the FTP server and stores it under the specified file name, creating a new local file in the process.

FtpGetFileEx

This function retrieves a file from the FTP server and stores it under the specified file name, creating a new local file in the process.

FtpGetFileSize

This function retrieves the file size of the requested FTP resource.

FtpOpenFile

This function initiates access to a remote file for writing or reading.

FtpPutFile

This function stores a file on the FTP server.

FtpPutFileEx

This function stores a file on the FTP server.

FtpRemoveDirectory

This function removes the specified directory on the FTP server.

FtpRenameFile

This function renames a file stored on the FTP server.

FtpSetCurrentDirectory

This function changes to a different working directory on the FTP server.

GetUrlCacheEntryInfo

This function retrieves data about a cache entry.

GetUrlCacheEntryInfoEx

This function searches for the Uniform Resource Locator (URL) after translating any cached redirections applied in offline mode by the HttpSendRequest function.

GetUrlCacheGroupAttribute

Retrieves the attribute information of the specified cache group.

HttpAddRequestHeaders

This function adds one or more Hypertext Transfer Protocol (HTTP) request headers to the HTTP request handle.

HttpEndRequest

This function ends an HTTP request that was initiated by HttpSendRequestEx.

HttpOpenRequest

This function opens an HTTP request handle.

HttpQueryInfo

This function queries for information about an HTTP request.

INTERNET_STATUS_CALLBACK

This function is a prototype for an application-defined status callback function.

InternetAttemptConnect

This function attempts to make a connection to the Internet.

InternetCheckConnection

This function allows an application to check if a connection to the Internet can be established.

InternetCloseHandle

This function closes a single Internet handle or a subtree of Internet handles.

InternetCombineUrl

This function combines a base and relative URL into a single URL. The resultant URL is canonicalized.

InternetConfirmZoneCrossing

This function checks for changes between secure and nonsecure URLs.

InternetConnect

This function opens an FTP or HTTP session for a specified site.

InternetCrackUrl

This function breaks down a URL into its component parts.

InternetCreateUrl

This function creates a URL from its component parts.

InternetErrorDlg

This function displays a dialog box for the error that is passed to it, if an appropriate dialog box exists.

InternetFindNextFile

This function continues a file search from a previous call to FtpFindFirstFile.

InternetGetConnectedState

This function retrieves the connected state of the local system.

InternetGetConnectedStateEx

This function retrieves the connected state of the specified Internet connection.

InternetGetCookie

This function retrieves the cookie for the specified URL.

InternetGetLastResponseInfo

This function retrieves the last WinInet function error description or server response on the thread calling this function.

InternetGoOnline

This function prompts the user for permission to initiate connection to a URL.

InternetLockRequestFile

This function allows the user to place a lock on the file that is being used.

InternetOpen

This function initializes an application's use of the WinInet functions.

InternetOpenUrl

This function begins reading a complete FTP or HTTP Universal Resource Locator (URL).

InternetQueryDataAvailable

This function queries the amount of data available.

InternetQueryOption

This function queries an Internet option on the specified handle.

InternetReadFile

This function reads data from a handle opened by the InternetOpenUrl, FtpOpenFile, or HttpOpenRequest function.

InternetReadFileEx

This function reads data from a handle opened by the InternetOpenUrl, FtpOpenFile, or HttpOpenRequest function.

InternetSetCookie

This function creates a cookie associated with the specified URL.

InternetSetCookieEx

This function creates a cookie associated with the specified URL.

InternetSetFilePointer

This function sets a file position for InternetReadFile.

InternetSetOption

This function sets an Internet option on the specified handle.

InternetSetOptionEx

This function sets an Internet option.

InternetSetStatusCallback

This function sets up a callback function that WinInet functions can call as progress is made during an operation.

InternetTimeFromSystemTime

This function formats a date and time according to the specified RFC format — as specified in the Hypertext Transfer Protocol (HTTP) Specification 1.0.

InternetTimeToSystemTime

This function takes an HTTP time/date string and converts it to a SYSTEMTIME structure.

InternetUnlockRequestFile

This function unlocks a file that was locked using InternetLockRequestFile.

InternetWriteFile

This function writes data to an open Internet file.

ReadUrlCacheEntryStream

Reads the cached data from a stream that has been opened using the RetrieveUrlCacheEntryStream function.

RetrieveUrlCacheEntryFile

This function locks the cache entry file associated with the specified URL.

RetrieveUrlCacheEntryStream

This function provides the most efficient and implementation-independent way to access the cache data.

SetUrlCacheEntryGroup

This function adds entries to or removes entries from a cache group.

SetUrlCacheGroupAttribute

This function sets the attribute information of the specified cache group.

SetUrlCacheEntryInfo

This function sets the specified members of the INTERNET_CACHE_ENTRY_INFO structure.

UnlockUrlCacheEntryFile

This function unlocks the cache entry that was locked while the file was retrieved for use from the cache.

UnlockUrlCacheEntryStream

This function closes the stream that has been retrieved using the RetrieveUrlCacheEntryStream function

InternetSetPerSiteCookieDecisionA

Sets a decision on cookies for a given domain. ANSI implementation.

InternetSetPerSiteCookieDecisionW

Sets a decision on cookies for a given domain. Unicode implementation.

InternetGetPerSiteCookieDecisionA

Retrieves a decision on cookies for a given domain. ANSI implementation.

InternetGetPerSiteCookieDecisionW

Retrieves a decision on cookies for a given domain. Unicode implementation.

InternetClearAllPerSiteCookieDecisions

Clears all decisions that were made about cookies on a site by site basis.

InternetEnumPerSiteCookieDecisionA

Retrieves the domains and cookie settings of Web sites for which site-specific cookie regulations are set. ANSI implementation.

InternetEnumPerSiteCookieDecisionW

Retrieves the domains and cookie settings of Web sites for which site-specific cookie regulations are set. Unicode implementation.

PrivacySetZonePreferenceW

Retrieves the privacy settings for a given URLZONE and PrivacyType. Unicode implementation.

PrivacyGetZonePreferenceW

Sets the privacy settings for a given URLZONE and PrivacyType. Unicode implementation.