Hi Pedro,
thanks for your contribution.
Regards
Piotr
Testing internet connection
Re: Testing internet connection
Always, Your Welcome
Re: Testing internet connection
Pedro,
maybe I make some wrong, but the DLL function InternetGetConnectedState() return 1 when computer is connected via router into internet and return the same when computer is not connected into router (and don't have onnection with internet). Why?
Piotr
maybe I make some wrong, but the DLL function InternetGetConnectedState() return 1 when computer is connected via router into internet and return the same when computer is not connected into router (and don't have onnection with internet). Why?
Piotr
Re: Testing internet connection
you have to wait 30Sec.Piotr D wrote:maybe I make some wrong, but the DLL function InternetGetConnectedState() return 1 when computer is connected via router into internet and return the same when computer is not connected into router (and don't have onnection with internet). Why?
greetings by OHR
Jimmy
Jimmy
Re: Testing internet connection
Jimmy,
what are you meant? Don't understand.
Piotr
what are you meant? Don't understand.

Piotr
Re: Testing internet connection
i did test it with a USB WiFi Stick.Piotr D wrote:what are you meant? Don't understand.![]()
after "eject" USB the Function still show "Y". so i wrote a loop and after 30 Sec. it show "N"
IMHO the Function only show if you have a connection to Internet but it does not say that you can connect to a Website.
greetings by OHR
Jimmy
Jimmy
- slobodan1949
- Posts: 89
- Joined: Mon Apr 25, 2011 8:57 am
- Location: SERBIA
- Contact:
Re: Testing internet connection CONCLUSION
(-- A --)
When I turn on the internet on my computer (Windows 11)
this function gives a message that the internet IS ACCESSIBLE
When I turn off the INTERNET on my computer (Windows 11)
this function still shows that the internet IS ACCESSIBLE:
#INCLUDE "dll.ch"
DLLFUNCTION InternetGetConnectedState( @nFlags, nReserved ) USING STDCALL FROM WinInet.Dll
* ---
FUNCTION Verify_Internet()
LOCAL lRet:=.T.
IF VerifyInternet() == .F.
MsgBox("INTERNET NOT AVAILABLE","STOP");lRet:=.F.
ELSE
MsgBox("INTERNET AVAILABLE","OK");lRet:=.T.
ENDIF
RETURN lRet
* ---
FUNCTION VerifyInternet()
Return ( InternetGetConnectedState(0,0) <> 0 ) // return=0, return<>0
* ---
QUESTION:
---------------
http://bb.donnay-software.com/Donnay/vi ... e&start=10
DLL function InternetGetConnectedState() return 1
when computer is connected via router into internet
and return the same when computer is not connected
into router (and don't have onnection with internet). Why?
The only answer:
---------------------
you have to wait 30Sec.
i did test it with a USB WiFi Stick.
after "eject" USB the Function still show "Y".
so i wrote a loop and after 30 Sec. it show "N"
IMHO the Function only show if you have a connection
to Internet but it does not say that you can connect to a Website.
CONCLUSION: These two functions do not have that problem
--------------------------------------------------------------------------
(-- B --)
When I turn on the internet on my computer (Windows 11)
this function gives a message that the internet IS ACCESSIBLE
When I turn off the INTERNET on my computer (Windows 11)
this function shows that the internet IS INACCESSIBLE:
* ---
FUNCTION Verify_Internet()
aNet:=NetworkConnected("I") // "I"=INTERNET, "N"=NETWORK
IF aNet==.F.
MsgBox("INTERNET NOT AVAILABLE","STOP")
ELSE
MsgBox("INTERNET AVAILABLE","OK")
Endif
RETURN aNet
#pragma library( "ascom10.lib" )
* ---
STATIC FUNCTION NetworkConnected(pType)
LOCAL lConnected := .F., oNLM
#define CLSID_NetworkListManager "{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"
#define NLM_CONNECTIVITY_IPV4_INTERNET 0x0040
pType := IF(pType==NIL,"I",UPPER(pType))
oNLM:= CreateObject( CLSID_NetworkListManager )
IF pType == "I"
lConnected := oNLM:IsConnectedToInternet()
ELSEIF pType == "N"
lConnected := oNLM:IsConnected()
ENDIF
oNLM:destroy()
RETURN lConnected
* ---
(-- C --)
When I turn on the internet on my computer (Windows 11)
this function gives a message that the internet IS ACCESSIBLE
When I turn off the INTERNET on my computer (Windows 11)
this function shows that the internet IS INACCESSIBLE:
* ---
FUNCTION Verify_Internet() // Xbase++ 2.0
LOCAL oHC, cResult
oHC:=HttpClient():new( "http://www.google.rs" )
cResult:=oHC:send()
oHC:disconnect()
IF oHC:getStatusCode() != 200
MsgBox("INTERNET NOT AVAILABLE","STOP")
Return .f.
ENDIF
MsgBox("INTERNET AVAILABLE","OK")
RETURN .t.
* ---
When I turn on the internet on my computer (Windows 11)
this function gives a message that the internet IS ACCESSIBLE
When I turn off the INTERNET on my computer (Windows 11)
this function still shows that the internet IS ACCESSIBLE:
#INCLUDE "dll.ch"
DLLFUNCTION InternetGetConnectedState( @nFlags, nReserved ) USING STDCALL FROM WinInet.Dll
* ---
FUNCTION Verify_Internet()
LOCAL lRet:=.T.
IF VerifyInternet() == .F.
MsgBox("INTERNET NOT AVAILABLE","STOP");lRet:=.F.
ELSE
MsgBox("INTERNET AVAILABLE","OK");lRet:=.T.
ENDIF
RETURN lRet
* ---
FUNCTION VerifyInternet()
Return ( InternetGetConnectedState(0,0) <> 0 ) // return=0, return<>0
* ---
QUESTION:
---------------
http://bb.donnay-software.com/Donnay/vi ... e&start=10
DLL function InternetGetConnectedState() return 1
when computer is connected via router into internet
and return the same when computer is not connected
into router (and don't have onnection with internet). Why?
The only answer:
---------------------
you have to wait 30Sec.
i did test it with a USB WiFi Stick.
after "eject" USB the Function still show "Y".
so i wrote a loop and after 30 Sec. it show "N"
IMHO the Function only show if you have a connection
to Internet but it does not say that you can connect to a Website.
CONCLUSION: These two functions do not have that problem
--------------------------------------------------------------------------
(-- B --)
When I turn on the internet on my computer (Windows 11)
this function gives a message that the internet IS ACCESSIBLE
When I turn off the INTERNET on my computer (Windows 11)
this function shows that the internet IS INACCESSIBLE:
* ---
FUNCTION Verify_Internet()
aNet:=NetworkConnected("I") // "I"=INTERNET, "N"=NETWORK
IF aNet==.F.
MsgBox("INTERNET NOT AVAILABLE","STOP")
ELSE
MsgBox("INTERNET AVAILABLE","OK")
Endif
RETURN aNet
#pragma library( "ascom10.lib" )
* ---
STATIC FUNCTION NetworkConnected(pType)
LOCAL lConnected := .F., oNLM
#define CLSID_NetworkListManager "{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"
#define NLM_CONNECTIVITY_IPV4_INTERNET 0x0040
pType := IF(pType==NIL,"I",UPPER(pType))
oNLM:= CreateObject( CLSID_NetworkListManager )
IF pType == "I"
lConnected := oNLM:IsConnectedToInternet()
ELSEIF pType == "N"
lConnected := oNLM:IsConnected()
ENDIF
oNLM:destroy()
RETURN lConnected
* ---
(-- C --)
When I turn on the internet on my computer (Windows 11)
this function gives a message that the internet IS ACCESSIBLE
When I turn off the INTERNET on my computer (Windows 11)
this function shows that the internet IS INACCESSIBLE:
* ---
FUNCTION Verify_Internet() // Xbase++ 2.0
LOCAL oHC, cResult
oHC:=HttpClient():new( "http://www.google.rs" )
cResult:=oHC:send()
oHC:disconnect()
IF oHC:getStatusCode() != 200
MsgBox("INTERNET NOT AVAILABLE","STOP")
Return .f.
ENDIF
MsgBox("INTERNET AVAILABLE","OK")
RETURN .t.
* ---