SABER SE ESTA CONECTADO A NET QUE FUNCIONE

USUARIO.EXCLUIDOS 25/08/2006 11:59:08
#167254
Estou usando este exemplo:

Private Const INTERNET_CONNECTION_CONFIGURED = &H40
Private Const INTERNET_CONNECTION_LAN = &H2
Private Const INTERNET_CONNECTION_MODEM = &H1
Private Const INTERNET_CONNECTION_OFFLINE = &H20
Private Const INTERNET_CONNECTION_PROXY = &H4
Private Const INTERNET_RAS_INSTALLED = &H10
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
[c]Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim Ret As Long
Me.AutoRedraw = True
'retrieve the connection status
InternetGetConnectedState Ret, 0&
'show the result
If (Ret And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED Then Me.Print "Local system has a valid connection to the Internet, but it may or may not be currently connected."
If (Ret And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then Me.Print "Local system uses a local area network to connect to the Internet."
If (Ret And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then Me.Print "Local system uses a modem to connect to the Internet."
If (Ret And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE Then Me.Print "Local system is in offline mode."
If (Ret And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then Me.Print "Local system uses a proxy server to connect to the Internet."
If (Ret And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then Me.Print "Local system has RAS installed."
End Sub


Mas ele só funciona quando inicio a aplicação. ਠpossível dar um refresh, ou refazer? preciso verificar a conexão a cada 20 segundos e não estou conseguindo.

Obrigado.
[/c]
USUARIO.EXCLUIDOS 25/08/2006 12:07:36
#167259
Sim.

Coloque um timer em seu projeto. Defina a propriedade Interval para 60000. Então coloque o seguinte código em seu timer:

conta = conta + 1

if conta = 20 then
conta = 0

'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim Ret As Long
Me.AutoRedraw = True
'retrieve the connection status
InternetGetConnectedState Ret, 0&
'show the result
If (Ret And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED Then Me.Print "Local system has a valid connection to the Internet, but it may or may not be currently connected."
If (Ret And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then Me.Print "Local system uses a local area network to connect to the Internet."
If (Ret And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then Me.Print "Local system uses a modem to connect to the Internet."
If (Ret And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE Then Me.Print "Local system is in offline mode."
If (Ret And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then Me.Print "Local system uses a proxy server to connect to the Internet."
If (Ret And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then Me.Print "Local system has RAS installed."

end if


Qualquer coisa eu monto um exemplo pra vc.
USUARIO.EXCLUIDOS 25/08/2006 12:16:51
#167262
Mudei de Exemplo e funcionou.

http://www.vbmania.com.br/vbmania/vbmdetail.php?varID=165&TxtSearch=Internet&CmbSort=ftitulo&varPagina=1
USUARIO.EXCLUIDOS 25/08/2006 12:25:47
#167265
Sem problemas!!

falta somente encerrar o tópico então!! rsrs
Tópico encerrado , respostas não são mais permitidas