I want to write a VB6 program to measure the duration of time I am connected to the internet (dial up connection). Any idea?
Printable View
I want to write a VB6 program to measure the duration of time I am connected to the internet (dial up connection). Any idea?
A google search returned me this page.
From that page:
I've never used that API either.Quote:
Originally Posted by Gale of TheMSsForum.com
add thise to check if your connectedCode:Private Declare Function InternetGetConnectedState _
Lib "wininet.dll" (ByRef lpdwFlags As Long, _
ByVal dwReserved As Long) As Long
Return true if connected, false if not.
found here!Code:B = (InternetGetConnectedState(0&, 0&) <> 0)
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.
Thanx a lot snortop & iprank. :)
I will give it a try and inform.
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? :)
Well i just found out the is a cool page of all Api.
Here i found thise code.
there you can see that it can also check if you use a modem connection!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
Check more here, under internet.
Thanx Snortop :) That was nice.
Now I have another question.
How to get the amount of Data uploaded/downloaded ? :confused: