Create Cursor myCursor (contents m)
Public oForm
oForm = Createobject("form")
oForm.AddObject("edit1","editbox")
oForm.edit1.Visible=.T.
oForm.Height = 400
oForm.Width = 400
oForm.edit1.Width=390
oForm.edit1.Height=390
oForm.AutoCenter=.T.
oForm.edit1.ControlSource = "mycursor.contents"
SELECT myCursor
Append Blank
Replace contents With FETCHURL( "[URL unfurl="true"]http://www.microsoft.com"[/URL] )
oForm.Show(1)
Function FETCHURL
Lparameters pcUrlName
Declare Integer InternetOpen In wininet.Dll String sAgent, ;
INTEGER lAccessType, String sProxyName, ;
STRING sProxyBypass, Integer lFlags
Declare Integer InternetOpenUrl In wininet.Dll ;
INTEGER hInternetSession, String sUrl, String sHeaders, ;
INTEGER lHeadersLength, Integer lFlags, Integer lContext
Declare Integer InternetReadFile In wininet.Dll Integer hfile, ;
STRING @sBuffer, Integer lNumberofBytesToRead, Integer @lBytesRead
Declare short InternetCloseHandle In wininet.Dll Integer hInst
#Define INTERNET_OPEN_TYPE_PRECONFIG 0
#Define INTERNET_OPEN_TYPE_DIRECT 1
#Define INTERNET_OPEN_TYPE_PROXY 3
#Define SYNCHRONOUS 0
#Define INTERNET_FLAG_RELOAD 2147483648
#Define CR Chr(13)
Local lsAgent, lhInternetSession, lhUrlFile, llOk, lnOk, lcRetVal, lcReadBuffer, lnBytesRead
lsAgent = "VPF"
lhInternetSession = InternetOpen( lsAgent, INTERNET_OPEN_TYPE_PRECONFIG, ;
'', '', SYNCHRONOUS)
If lhInternetSession = 0
Wait Window "Internet session cannot be established" Time 2
Return .Null.
Endif
lhUrlFile = InternetOpenUrl( lhInternetSession, pcUrlName, '', 0, ;
INTERNET_FLAG_RELOAD, 0)
If lhUrlFile = 0
Wait Window "URL cannot be opened"
Return .Null.
Endif
lcRetVal = ""
llOk = .T.
Do While llOk
lsReadBuffer = Space(32767)
lnBytesRead = 0
lnOk = InternetReadFile( lhUrlFile, @lsReadBuffer, Len(lsReadBuffer), @lnBytesRead)
If ( lnBytesRead > 0 )
lcRetVal = lcRetVal + Left( lsReadBuffer, lnBytesRead )
Endif
llOk = ( lnOk = 1 ) And ( lnBytesRead > 0 )
Enddo
InternetCloseHandle( lhUrlFile )
InternetCloseHandle( lhInternetSession )
Return lcRetVal
Endfunc