Notifications
Clear all

Verificar se esta conectado na Internet

1 Posts
1 Usuários
0 Reactions
661 Visualizações
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Esta rotina permite verificar se o computador esta conectado na internet e o tipo de conexão usada para acessar a mesma.

Private Declare Function InternetGetConnectedState Lib "wininet" (ByRef dwflags As Long, ByVal dwReserved As Long) As Long
Private Const CONNECT_LAN As Long = &H2
Private Const CONNECT_MODEM As Long = &H1
Private Const CONNECT_PROXY As Long = &H4
Private Const CONNECT_RAS As Long = &H10
Private Const CONNECT_OFFLINE As Long = &H20
Private Const CONNECT_CONFIGURED As Long = &H40

Public Enum TipoConexao
    Lan
    Modem
    Proxy
    Remota
    Configurada
    OffLine
End Enum

'---------------------------------------------------------------------------------------
' Procedure  : VerificaConexao
' Data       : 19/02/2010
' Programador: Rodrigo
' Contato    : thabis.wired@hotmail.com
' Descrição  : Verifica se esta conectado da internet e o tipo de conexão
'---------------------------------------------------------------------------------------
'
Public Function VerificaConexao() As TipoConexao
Dim dwflags As Long
Dim WebTest As Boolean

On Error GoTo VerificaConexao_Error

ConnType = ""

WebTest = InternetGetConnectedState(dwflags, 0&)

Select Case WebTest
    Case dwflags And CONNECT_LAN
        VerificaConexao = Lan
    Case dwflags And CONNECT_MODEM
        VerificaConexao = Modem
    Case dwflags And CONNECT_PROXY
        VerificaConexao = Proxy
    Case dwflags And CONNECT_OFFLINE
        VerificaConexao = OffLine
    Case dwflags And CONNECT_CONFIGURED
        VerificaConexao = Configurada
    Case dwflags And CONNECT_RAS
        VerificaConexao = Remota
End Select

Exit Function
VerificaConexao_Error:
    MsgBox "Erro: " & Err.Number & vbNewLine & "Procedure VerificaConexao localizado em Módulo1, na linha " & Erl, vbCritical, Err.Source
End Function
 
Postado : 19/02/2010 8:56 am