Como puedo detectar si hay conexion de red desde visual basic??
Buenas tardes espero que alguien pueda ayudarme, tengo que hacer una aplicacion en Visual Basic 6 en la cual se pueda estar comprobando si hay conexion de red, esto, para en caso de que se desconecte el cable de red, por ejemplo, haga unas operaciones y cuando detecte que ya hay conexion, envie un mensaje diciendo que ya se recupero nuevamente la red..., alguien tiene idea de como hacer esto, espero me puedan ayudar
Muchas gracias
------------------------
Saludos
Atte: Juan Pablo Garcia
------------------------
Muchas gracias
------------------------
Saludos
Atte: Juan Pablo Garcia
------------------------
O.k.
Talves te sirva esto:
--------------------------------------------------------------------------
Option Explicit
Public Declare Function RasEnumConnections Lib \"RasApi32.dll\" Alias \"RasEnumConnectionsA\" (lpRasCon As Any, lpcb As Long, lpcConnections As Long) As Long
Public Declare Function RasGetConnectStatus Lib \"RasApi32.dll\" Alias \"RasGetConnectStatusA\" (ByVal hRasCon As Long, lpStatus As Any) As Long
Public Const RAS95_MaxEntryName = 256
Public Const RAS95_MaxDeviceType = 16
Public Const RAS95_MaxDeviceName = 32
Public Type RASCONN95
dwSize As Long
hRasCon As Long
szEntryName(RAS95_MaxEntryName) As Byte
szDeviceType(RAS95_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
Public Type RASCONNSTATUS95
dwSize As Long
RasConnState As Long
dwError As Long
szDeviceType(RAS95_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
Public Function hayConexion() As Boolean
Dim TRasCon(255) As RASCONN95
Dim lg As Long
Dim lpcon As Long
Dim RetVal As Long
Dim Tstatus As RASCONNSTATUS95
TRasCon(0).dwSize = 412
lg = 256 * TRasCon(0).dwSize
RetVal = RasEnumConnections(TRasCon(0), lg, lpcon)
If RetVal <> 0 Then
MsgBox \"Error \" & Err.number & vbcrlf & vbcrlf & Err.despcription
Exit Function
End If
Tstatus.dwSize = 160
RetVal = RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)
If Tstatus.RasConnState = &H2000 Then
hayConexion= True
Else
hayConexion= False
End If
End Function
---------------------------------------------------------------------------
Para saber si hay conexion solo tienes que llamar a la funcion de esta manera:
VariableBoolean = HayConexion()
If variableBoolean then
\\'Acciones
else
\\'Acciones
end if
o
if hayconexion then
\\'Acciones
Else
\\'Acciones
End if
O.k. espero que te sirva... Saludos!
. : DarkSoft : .
Talves te sirva esto:
--------------------------------------------------------------------------
Option Explicit
Public Declare Function RasEnumConnections Lib \"RasApi32.dll\" Alias \"RasEnumConnectionsA\" (lpRasCon As Any, lpcb As Long, lpcConnections As Long) As Long
Public Declare Function RasGetConnectStatus Lib \"RasApi32.dll\" Alias \"RasGetConnectStatusA\" (ByVal hRasCon As Long, lpStatus As Any) As Long
Public Const RAS95_MaxEntryName = 256
Public Const RAS95_MaxDeviceType = 16
Public Const RAS95_MaxDeviceName = 32
Public Type RASCONN95
dwSize As Long
hRasCon As Long
szEntryName(RAS95_MaxEntryName) As Byte
szDeviceType(RAS95_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
Public Type RASCONNSTATUS95
dwSize As Long
RasConnState As Long
dwError As Long
szDeviceType(RAS95_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
Public Function hayConexion() As Boolean
Dim TRasCon(255) As RASCONN95
Dim lg As Long
Dim lpcon As Long
Dim RetVal As Long
Dim Tstatus As RASCONNSTATUS95
TRasCon(0).dwSize = 412
lg = 256 * TRasCon(0).dwSize
RetVal = RasEnumConnections(TRasCon(0), lg, lpcon)
If RetVal <> 0 Then
MsgBox \"Error \" & Err.number & vbcrlf & vbcrlf & Err.despcription
Exit Function
End If
Tstatus.dwSize = 160
RetVal = RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)
If Tstatus.RasConnState = &H2000 Then
hayConexion= True
Else
hayConexion= False
End If
End Function
---------------------------------------------------------------------------
Para saber si hay conexion solo tienes que llamar a la funcion de esta manera:
VariableBoolean = HayConexion()
If variableBoolean then
\\'Acciones
else
\\'Acciones
end if
o
if hayconexion then
\\'Acciones
Else
\\'Acciones
End if
O.k. espero que te sirva... Saludos!
. : DarkSoft : .