Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Internet

Internet

Scheduled Pinned Locked Moved Visual Basic
helpquestionworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    hi.. could u pls help in getting the code for checking whether an internet connection was setup or not in vb?

    N 1 Reply Last reply
    0
    • A Anonymous

      hi.. could u pls help in getting the code for checking whether an internet connection was setup or not in vb?

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Try something like this, there are actually several ways to check for something like this, but they all differ slightly.

      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
      Private Sub Form_Load()
      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

      Nick Parker
      **The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown


      **

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups