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. How do I check if a user is online?

How do I check if a user is online?

Scheduled Pinned Locked Moved Visual Basic
questionhelp
3 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.
  • J Offline
    J Offline
    JackIsMe777
    wrote on last edited by
    #1

    I have created a program that will access a webpage online using the built-in web browser in visual basic 2005 express, but if the user is NOT online, they get an ugly "Page Cannot Be Displayed" page. I want to be able to validate that the user is online so that I can redirect them to a custom page that I will store on their hard drive if necessary. I am fairly new to vb, and would appreciate any help I can get. Thanks in advance!!

    L 1 Reply Last reply
    0
    • J JackIsMe777

      I have created a program that will access a webpage online using the built-in web browser in visual basic 2005 express, but if the user is NOT online, they get an ugly "Page Cannot Be Displayed" page. I want to be able to validate that the user is online so that I can redirect them to a custom page that I will store on their hard drive if necessary. I am fairly new to vb, and would appreciate any help I can get. Thanks in advance!!

      L Offline
      L Offline
      Leeland
      wrote on last edited by
      #2

      I got the following code from http://www.devx.com/vb2themax/Tip/19159[^] I haven't tested it, but it appears to be just a matter of making sure the wininet.dll is in the system directory and then calling IsConnectedToInternet function from your code. If it returns true you're connected, if false you're not. They you just change the location based on the response. Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef _ lpSFlags As Long, ByVal dwReserved As Long) As Long Const INTERNET_CONNECTION_MODEM = 1 Const INTERNET_CONNECTION_LAN = 2 Const INTERNET_CONNECTION_PROXY = 4 Const INTERNET_CONNECTION_MODEM_BUSY = 8 ' return True if there is an active Internect connection ' ' optionally returns the connection mode through ' its argument (see INTERNET_CONNECTION_* constants) ' 1=modem, 2=Lan, 4=proxy ' 8=modem busy with a non-internet connection Function IsConnectedToInternet(Optional connectMode As Integer) As Boolean Dim flags As Long ' this ASPI function does it all IsConnectedToInternet = InternetGetConnectedState(flags, 0) ' return the flag through the optional argument connectMode = flags End Function

      J 1 Reply Last reply
      0
      • L Leeland

        I got the following code from http://www.devx.com/vb2themax/Tip/19159[^] I haven't tested it, but it appears to be just a matter of making sure the wininet.dll is in the system directory and then calling IsConnectedToInternet function from your code. If it returns true you're connected, if false you're not. They you just change the location based on the response. Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef _ lpSFlags As Long, ByVal dwReserved As Long) As Long Const INTERNET_CONNECTION_MODEM = 1 Const INTERNET_CONNECTION_LAN = 2 Const INTERNET_CONNECTION_PROXY = 4 Const INTERNET_CONNECTION_MODEM_BUSY = 8 ' return True if there is an active Internect connection ' ' optionally returns the connection mode through ' its argument (see INTERNET_CONNECTION_* constants) ' 1=modem, 2=Lan, 4=proxy ' 8=modem busy with a non-internet connection Function IsConnectedToInternet(Optional connectMode As Integer) As Boolean Dim flags As Long ' this ASPI function does it all IsConnectedToInternet = InternetGetConnectedState(flags, 0) ' return the flag through the optional argument connectMode = flags End Function

        J Offline
        J Offline
        JackIsMe777
        wrote on last edited by
        #3

        I'm really new to vb and don't understand this code or how to use it... Does anyone out there know how I can impliment this into my program... Thanks.

        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