Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Runtime.InteropServices
- Imports System.Threading.Tasks
- Public Class Cls_Internet
- #Region " Enumerations "
- Private Enum InternetConnectionStates
- Unknown = 0
- Modem = 1
- LAN = 2
- Proxy = 4
- RasInstalled = 16
- Offline = 32
- Configured = 64
- End Enum
- #End Region
- #Region " Win32 "
- <DllImport("wininet.dll")> _
- Private Shared Function InternetGetConnectedState(ByRef lpdwFlags As InternetConnectionStates, dwReserved%) As Boolean
- End Function
- #End Region
- #Region " Methods "
- Public Shared Function IsConnectedToInternet() As Boolean
- Return Threading.Tasks.Task(Of Boolean).Factory.StartNew(Function() IsConnectedToInternet(InternetConnectionStates.Unknown)).Result
- End Function
- Private Shared Function IsConnectedToInternet(ByRef connectionStates As InternetConnectionStates) As Boolean
- Return InternetGetConnectedState(connectionStates, 0)
- End Function
- #End Region
- End Class
- '############################### Comment l'utiliser ###########################
- MsgBox(If(Cls_Internet.IsConnectedToInternet() = True, "Vous êtes connectés à Internet", "Vous n'êtes pas connectés à Internet"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement