PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → Wx - Verificando se tem internet
Wx - Verificando se tem internet
Débuté par adrianoboller, 31 oct. 2015 16:53 - 3 réponses
Membre enregistré
3 655 messages
Popularité : +175 (223 votes)
Posté le 31 octobre 2015 - 16:53
Procedure ConexaoInternet()

GloConexaoInternet = 0

ok is boolean = False

PosicaoOK is int = 0

Httpurl, HttpRetorno is string

Httpurl = "http://www.google.com.br"

HTTPTimeOut(GloHTTPTimeOut)

IF HTTPRequest(Httpurl) = True AND Httpurl <> "" THEN

HttpRetorno = HTTPGetResult(httpHeader)

PosicaoOK = PositionOccurrence(HttpRetorno,"Connection",firstRank,IgnoreCase)
IF PosicaoOK = 0 THEN
PosicaoOK = PositionOccurrence(Upper(HttpRetorno),"200",firstRank,IgnoreCase)
IF PosicaoOK = 0 THEN
PosicaoOK = PositionOccurrence(Upper(HttpRetorno),"OK",firstRank,IgnoreCase)
END
END

IF Httpurl <> "" AND PosicaoOK > 0 AND HttpRetorno <> "" THEN
GloConexaoInternet = 1
ok = True
ELSE
GloConexaoInternet = 0
ok = False
END

ELSE
GloConexaoInternet = 0
ok = False
END

RESULT(ok)

//Se retorno for true tem se nao nao tem internet


--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
3 655 messages
Popularité : +175 (223 votes)
Posté le 31 octobre 2015 - 16:57
Prezados,

Outra forma de verificar se tem internet é usando o comando nativo:

ResConnection = InternetConnected()
IF ResConnection = True THEN
Info("An Internet connection is enabled")
ELSE
Info("No Internet connection is enabled")
END


Link complementar:
http://help.windev.com/en-US/…

--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
13 messages
Popularité : +9 (9 votes)
Posté le 09 novembre 2015 - 17:45
Show Funcionou perfeitamente!
Membre enregistré
3 655 messages
Popularité : +175 (223 votes)
Posté le 18 janvier 2018 - 14:01
// Résumé : <indiquez ici ce que fait la procédure>
// Syntaxe :
//[ <Résultat> = ] VerificaWebservice (<WebserviceURL>, <nTimeOut>)
//
// Paramètres :
// WebserviceURL : <indiquez ici le rôle de WebserviceURL>
// nTimeOut : <indiquez ici le rôle de nTimeOut>
// Valeur de retour :
// booléen : // Aucune
//
// Exemple :
// Indiquez ici un exemple d'utilisation.
//
Procedure VerificaWebservice(WebserviceURL, nTimeOut)

ok is boolean = False

PosicaoOK is int = 0

HttpRetorno is string

IF WebserviceURL = ""
WebserviceURL = "http://www.google.com.br"
END

IF nTimeOut = 0 OR nTimeOut = "" THEN
nTimeOut = 3000 //3s
END

HTTPTimeOut(nTimeOut)

IF httpRequest(WebserviceURL) = True THEN

HttpRetorno = HTTPGetResult(httpHeader)

PosicaoOK = PositionOccurrence(HttpRetorno,"Connection",firstRank,IgnoreCase)
IF PosicaoOK = 0 THEN
PosicaoOK = PositionOccurrence(Upper(HttpRetorno),"200",firstRank,IgnoreCase)
IF PosicaoOK = 0 THEN
PosicaoOK = PositionOccurrence(Upper(HttpRetorno),"OK",firstRank,IgnoreCase)
END
END

IF WebserviceURL <> "" AND PosicaoOK > 0 AND HttpRetorno <> "" THEN
ok = True
ELSE
ok = False
END

ELSE
ok = False
END

RESULT(ok)


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/