Results 1 to 7 of 7

Thread: Duration of Internet connection

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Duration of Internet connection

    I want to write a VB6 program to measure the duration of time I am connected to the internet (dial up connection). Any idea?

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Duration of Internet connection

    A google search returned me this page.
    From that page:
    Quote Originally Posted by Gale of TheMSsForum.com
    All this type of information is held by RAS.

    I've never had cause to use the function so I can't give you an
    example but it would appear that the API you need is
    MprAdminConnectionGetInfo.

    This will return either a RAS_CONNECTION_0 structure or a
    RAS_CONNECTION_1 structure, for a given RAS Connection.

    The first structure includes the current duration of the connection
    and the second includes the bytes transmitted and received so far on
    the connection.

    If you don't have a handle to the connection then you'll need to use
    RasEnumConnections to get one.
    I've never used that API either.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3
    Lively Member
    Join Date
    Feb 2008
    Location
    Denmark
    Posts
    113

    Re: Duration of Internet connection

    Code:
    Private Declare Function InternetGetConnectedState _
        Lib "wininet.dll" (ByRef lpdwFlags As Long, _
        ByVal dwReserved As Long) As Long
    add thise to check if your connected

    Return true if connected, false if not.
    Code:
    B = (InternetGetConnectedState(0&, 0&) <> 0)
    found here!
    http://www.pscode.com/vb/scripts/Sho...36109&lngWId=1

    And for the duration check, guess you just make a timer from where i start getting a hit on connection until it lost connection.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Duration of Internet connection

    Thanx a lot snortop & iprank.

    I will give it a try and inform.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Duration of Internet connection

    Works fine. Thanks a lot.

    But when I am on the LAN it always shows as connected. So I have to disable the LAN to get the correct position. Any workaround for this?

  6. #6
    Lively Member
    Join Date
    Feb 2008
    Location
    Denmark
    Posts
    113

    Re: Duration of Internet connection

    Well i just found out the is a cool page of all Api.

    Here i found thise code.
    Code:
    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()
        'KPD-Team 2001
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        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
    there you can see that it can also check if you use a modem connection!

    Check more here, under internet.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Duration of Internet connection

    Thanx Snortop That was nice.

    Now I have another question.

    How to get the amount of Data uploaded/downloaded ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width