Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check for Internet Connection
Message
 
 
To
20/02/2011 14:32:42
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP1
Miscellaneous
Thread ID:
01500982
Message ID:
01501009
Views:
102
Check also this thread Re: Internet connection test revival Thread #1498390

>My application checks for an internet connection. Users are not normally on a LAN, but have an individual ISP, dial-up, broadband or air-card.
>
>I've found these routines posted previously here.
>Example 1:
>
>Declare Integer InternetCheckConnection In wininet;
>	STRING lpszUrl, Integer dwFlags, Integer dwReserved
>#Define FLAG_ICC_FORCE_CONNECTION  1
>= _check ("http://www.microsoft.com")
>Procedure _check(lcUrl)
>gcConnectionStatus = (InternetCheckConnection(lcUrl, FLAG_ICC_FORCE_CONNECTION, 0)=1)
>oSocket = Createobject("MSWinsock.Winsock")
>
>Clear Dlls "InternetCheckConnection"
>
>If ! oSocket.LocalIP = "127.0.0.1"
>	gcIpAddress=oSocket.LocalIP
>	gcConnectionStatus = 'IP Address'
>Else
>	gcIpAddress=''
>	gcConnectionStatus = 'Not Connected'
>ENDIF
>
>
>Example 2:
>
>Local lcTempFile, loWSH  &&&, gcIPAddress
>lcTempFile="LocalIP.txt"
>If File(lcTempFile)		&&erase leftovers from old run
>	Erase (lcTempFile)
>Endif
>loWSH=Createobject("Wscript.Shell")
>loWSH.Run("command /c ipconfig > "+lcTempFile,0,1)
>If File(lcTempFile)		&&read the file and parse it
>	gcIpAddress=Upper(Filetostr(lcTempFile))
>	gcIpAddress=Substr(gcIpAddress, At('IP ADDRESS',gcIpAddress))
>	gcIpAddress=Substr(gcIpAddress, At(':',gcIpAddress)+2)
>	gcIpAddress=Substr(gcIpAddress, 1, At(Chr(13),gcIpAddress)-1)
>Endif
>If File(lcTempFile)		&&erase leftovers from old run
>	Erase (lcTempFile)
>Endif
>If Len(Alltrim(gcIpAddress)) = 0
>	gcConnectionStatus = 'Not Connected'
>Else
>	gcConnectionStatus = 'IP Address'
>Endif
>
>
>My questions are:
>Is Example # 1 subject to errors related to presence (or absence) of MSWinsock?
>Is Example # 2 particularly vulnerable to viruses?
>
>Thanks.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform