TInternet

Source: source/classes/internet.prg

Inherits from: none (base class)

TInternet is the base class for WinInet-based internet access in FWH. It manages a global WinInet session handle and provides a factory method for creating TFTP connections. The class uses a reference-counted singleton pattern for the WinINet session handle.

Key DATA Members

DATATypeDescription
hWinINetHandle(Class data) Handle to the opened WinINet.dll
hSessionHandle(Class data) Handle of the current WinINet session (InternetOpen)
nCountNumeric(Class data) Reference count of active TInternet objects
aFTPsArray(Class data) Array of all TFTP objects currently in use

Methods

MethodDescription
New()Create a new TInternet object; increments the session reference count and opens the WinINet session on first use
End()Release the internet object; decrements the reference count and closes the WinINet session when the count reaches zero
FTP( cFTPSite, cUserName, cPassword )Create and return a new TFTP object connected to the specified FTP site

Example: FTP File Upload via WinInet

#include "FiveWin.ch"

function Main()

   local oInet := TInternet():New()
   local oFtp  := oInet:FTP( "ftp.example.com", "user", "pass" )

   if oFtp:hFTP != nil
      oFtp:SetCurrentDirectory( "/uploads" )
      FtpPutFile( oFtp:hFTP, "c:\data\report.txt", "report.txt" )
      MsgInfo( "File uploaded successfully" )
   else
      MsgAlert( "FTP connection failed" )
   endif

   oFtp:End()
   oInet:End()

return nil

Notes

See Also