;use it For which you want, ITS FREE ; I used a bad translator on http://translate.google.com/translate_t
; because I am so tired
; (c) ses007, 2003
#INTERNET_CONNECTION_MODEM = $1
#INTERNET_CONNECTION_LAN = $2
#INTERNET_CONNECTION_PROXY = $4
#INTERNET_CONNECTION_MODEM_BUSY = $8
#INTERNET_CONNECTION_OFFLINE = $20
#INTERNET_CONNECTION_CONFIGURED = $40
#INTERNET_RAS_INSTALLED = $10
Procedure.s InternetStatus()
Protected dwflags.l, msg.s
If InternetGetConnectedState_(@dwflags, 0)
If dwflags & #INTERNET_CONNECTION_CONFIGURED
msg = msg + "An Internet connection is furnished." + Chr(10)
EndIf
If dwflags & #INTERNET_CONNECTION_LAN
msg = msg + "The Internet connection is made by a network"
EndIf
If dwflags & #INTERNET_CONNECTION_MODEM
msg = msg + "The Internet connection is made by a modem"
EndIf
If dwflags & #INTERNET_CONNECTION_PROXY
msg = msg + " and using a Proxy server." + Chr(10)
Else
msg = msg + "." + Chr(10)
EndIf
If dwflags & #INTERNET_CONNECTION_OFFLINE
msg = msg + "There is at present no Internet connection. "
EndIf
If dwflags & #INTERNET_CONNECTION_MODEM_BUSY
msg = msg + "The modem uses at present another connection."
EndIf
If dwflags & #INTERNET_RAS_INSTALLED
msg = msg + "A Remote Access Service (RAS) is installed."
EndIf
Else
msg = "There is at present no Internet connection."
EndIf
ProcedureReturn msg
EndProcedure
MessageRequester("Connection", InternetStatus(), 0)
EnableExplicit
Define NETWORK = #False
Define TCPIPv4 = #False
Define TCPIPv6 = #False
Define INTERNET= #False
If InitNetwork()
Define IP, IPv6$
NETWORK=#True
If ExamineIPAddresses(#PB_Network_IPv6)
Repeat
IP = NextIPAddress()
If IP
TCPIPv6=#True
IPv6$ = IPString(IP, #PB_Network_IPv6)
Debug "IPv6: " + IPv6$
FreeIP(IP)
EndIf
Until IP = 0
EndIf
Define IP, IPv4$
If ExamineIPAddresses()
Repeat
IP = NextIPAddress()
If IP
TCPIPv4=#True
IPv4$ = IPString(IP)
Debug "IPv4: " + IPv4$
EndIf
Until IP = 0
EndIf
Else
NETWORK=#False : Debug "Problème matériel ou logiciel sur le PC"
EndIf
DataSection
Liste_URL:
Data.s "http://api.ipify.org/?format=plain"
Data.s "http://ifconfig.co/ip"
Data.s "http://monip.outils-rezo.info/text"
Data.s "https://myip.dnsomatic.com"
Data.s "https://ipecho.net/plain"
Data.s "https://myexternalip.com/raw"
Data.s #Null$
EndDataSection
Define URL$, HttpRequest, StatusCode$, Response$, IPinternet$
Restore Liste_URL
Repeat
Read.s URL$
If URL$ <> #Null$
Debug URL$
HttpRequest = HTTPRequest(#PB_HTTP_Get, URL$, "", #PB_HTTP_NoRedirect)
If HttpRequest
StatusCode$ = Trim(HTTPInfo(HTTPRequest, #PB_HTTP_StatusCode))
Response$ = Trim(HTTPInfo(HTTPRequest, #PB_HTTP_Response))
FinishHTTP(HTTPRequest)
Debug "StatusCode: " + StatusCode$
Debug "Response: " + Response$
Debug #Null$
If StatusCode$ = "200"
INTERNET = #True
IPinternet$ = Response$
Break ; on teste toutes les URL jusqu'a en trouver une qui réponde
EndIf
EndIf
EndIf
Until URL$ = #Null$
Debug ""
Debug "NETWORK="+NETWORK
Debug "TCPIPv4="+TCPIPv4
Debug "TCPIPv6="+TCPIPv6
Debug "INTERNET="+INTERNET
Debug ""
Debug "IPv4="+IPv4$
Debug "IPv6="+IPv6$
Debug ""
Debug "IPinternet="+IPinternet$
End
On possède tous les éléments nécessaires a la suite des opérations.
CAGE
■ Win10 64-bit (Intel Celeron CPU N2920 @ 1.86GHz, 4,0GB RAM, Intel HD Graphics) & PB 6.00 LTS
■ Vivre et laisser vivre.
■ PureBasic pour le fun
■ Gérard sur le forum Anglais
■ Mes sites: http://pbcage.free.fr - http://yh.toolbox.free.fr
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !