Molim vas da mi pomognete. Pisem program za brojanje impulsa i vremena provedenog na internetu pa mi je potrebno da se program aktivira u trenutku kad se uspostavi veza sa internetom da bih onda merio vreme provedeno dok se ne diskonektuje. Ne znam kako da od Windowsa dobijem informaciju da je povezan sa internetom. Hvala unapred.
Internet konekcija
Zaključano
Zakačeno
Code:
Private Declare Function InetIsOffline Lib "url.dll" (ByVal dwFlags As Long) As Long
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'InetIsOffline returns 0 if you're connected
MsgBox "Are you connected to the internet? " + _
CStr(CBool(Not (InetIsOffline(0)))), vbInformation
End Sub
Private Declare Function InetIsOffline Lib "url.dll" (ByVal dwFlags As Long) As Long
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'InetIsOffline returns 0 if you're connected
MsgBox "Are you connected to the internet? " + _
CStr(CBool(Not (InetIsOffline(0)))), vbInformation
End Sub
Code:
Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _
(ByRef lpdwFlags As Long, ByVal lpszConnectionName As String, _
ByVal dwNameLen As Integer, ByVal dwReserved As Long) As Long
Dim sConnType As String * 255
Private Sub Form_Load()
Dim Ret As Long
Ret = InternetGetConnectedStateEx(Ret, sConnType, 254, 0)
If Ret = 1 Then
MsgBox "You are connected to Internet via a " & sConnType, vbInformation
Else
MsgBox "You are not connected to internet", vbInformation
End If
End Sub
Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _
(ByRef lpdwFlags As Long, ByVal lpszConnectionName As String, _
ByVal dwNameLen As Integer, ByVal dwReserved As Long) As Long
Dim sConnType As String * 255
Private Sub Form_Load()
Dim Ret As Long
Ret = InternetGetConnectedStateEx(Ret, sConnType, 254, 0)
If Ret = 1 Then
MsgBox "You are connected to Internet via a " & sConnType, vbInformation
Else
MsgBox "You are not connected to internet", vbInformation
End If
End Sub
Potpis
Hvala na pomoci. Imam samo jos jedno pitanje. Kako iz promenjive sConnType koja je duzine 255 da izdvojim samo ono sto je u njoj bez praznih polja. Probao sam sa komandom Trim$(sConnType) ali mi ne ide.
Probaj ovako
Code:
Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _
(ByRef lpdwFlags As Long, ByVal lpszConnectionName As String, _
ByVal dwNameLen As Integer, ByVal dwReserved As Long) As Long
Dim sConnType As String
Private Sub Form_Load()
Dim Ret As Long
Dim Pos As Long
sConnType = Space(255)
Ret = InternetGetConnectedStateEx(Ret, sConnType, 254, 0)
Pos = InStr(sConnType, vbNullChar)
If Pos > 0 Then sConnType = Left(sConnType, Pos - 1)
If Ret = 1 Then
MsgBox "You are connected to Internet via a " & sConnType, vbInformation
Else
MsgBox "You are not connected to internet", vbInformation
End If
End Sub
Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _
(ByRef lpdwFlags As Long, ByVal lpszConnectionName As String, _
ByVal dwNameLen As Integer, ByVal dwReserved As Long) As Long
Dim sConnType As String
Private Sub Form_Load()
Dim Ret As Long
Dim Pos As Long
sConnType = Space(255)
Ret = InternetGetConnectedStateEx(Ret, sConnType, 254, 0)
Pos = InStr(sConnType, vbNullChar)
If Pos > 0 Then sConnType = Left(sConnType, Pos - 1)
If Ret = 1 Then
MsgBox "You are connected to Internet via a " & sConnType, vbInformation
Else
MsgBox "You are not connected to internet", vbInformation
End If
End Sub