Saber si mi PC está conectado a internet

2046 vistas

Vamos a usar la función InternetGetConnectedState de la dll win32 wininet.dll



vbnet
  1. using System.Runtime.InteropServices;
  2.  
  3. ' declaración de la API
  4. Private Declare Function InternetGetConnectedState Lib "wininet.dll" ( _
  5.   ByRef lpdwFlags As Integer, _
  6.   ByVal dwReserved As Integer) As Boolean
  7.  
  8.  
  9. ' Uso del API
  10. Public Function IsConnected() as Boolean
  11.     Dim Desc As Integer
  12.     return InternetGetConnectedState(Desc, 0)
  13. End Function