|
-
Jun 15th, 2008, 02:23 AM
#1
Thread Starter
Hyperactive Member
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?
-
Jun 15th, 2008, 02:58 AM
#2
Re: Duration of Internet connection
A google search returned me this page.
From that page:
 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.
-
Jun 15th, 2008, 09:39 AM
#3
Lively Member
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.
-
Jun 15th, 2008, 08:59 PM
#4
Thread Starter
Hyperactive Member
Re: Duration of Internet connection
Thanx a lot snortop & iprank.
I will give it a try and inform.
-
Jun 16th, 2008, 01:34 AM
#5
Thread Starter
Hyperactive Member
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?
-
Jun 17th, 2008, 12:21 AM
#6
Lively Member
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.
-
Jun 20th, 2008, 01:41 PM
#7
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|