[ kiky @ 18.01.2005. 22:27 ] @
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.
[ mladenovicz @ 19.01.2005. 09:19 ] @
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


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
[ kiky @ 19.01.2005. 23:54 ] @
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.
[ mladenovicz @ 20.01.2005. 09:20 ] @
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