Results 1 to 2 of 2

Thread: checking internet conection

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309

    Thumbs up

    Hi,

    Does anybody know how detect is internet conection active and if yes then sent text massage to the email, or sent text file to the ftp.

    Please help me.

    (I need to count how many users use my program)

    [email protected]

  2. #2
    Guest
    Here's how to check for a connection:

    Declarations

    You must put the following code into the declarations section of your project.
    Code:
    Public Const ERROR_SUCCESS = 0&
    Public Const APINULL = 0&
    Public Const HKEY_LOCAL_MACHINE = &H80000002
    Public ReturnCode As Long
    
    Declare Function RegCloseKey Lib "advapi32.dll" (ByVal _
    hKey As Long) As Long
    
    Declare Function RegOpenKey Lib "advapi32.dll" Alias _
    "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As _
    String, phkResult As Long) As Long
    
    Declare Function RegQueryValueEx Lib "advapi32.dll" Alias _
    "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName _
    As String, ByVal lpReserved As Long, lpType As Long, _
    lpData As Any, lpcbData As Long) As Long
    Code
    Code:
    Public Function ActiveConnection() As Boolean
    Dim hKey As Long
    Dim lpSubKey As String
    Dim phkResult As Long
    Dim lpValueName As String
    Dim lpReserved As Long
    Dim lpType As Long
    Dim lpData As Long
    Dim lpcbData As Long
    ActiveConnection = False
    lpSubKey = "System\CurrentControlSet\Services\RemoteAccess"
    ReturnCode = RegOpenKey(HKEY_LOCAL_MACHINE, lpSubKey, _
    phkResult)
    
    If ReturnCode = ERROR_SUCCESS Then
        hKey = phkResult
        lpValueName = "Remote Connection"
        lpReserved = APINULL
        lpType = APINULL
        lpData = APINULL
        lpcbData = APINULL
        ReturnCode = RegQueryValueEx(hKey, lpValueName, _
        lpReserved, lpType, ByVal lpData, lpcbData)
        lpcbData = Len(lpData)
        ReturnCode = RegQueryValueEx(hKey, lpValueName, _
        lpReserved, lpType, lpData, lpcbData)
        
        If ReturnCode = ERROR_SUCCESS Then
            If lpData = 0 Then
                ActiveConnection = False
            Else
                ActiveConnection = True
            End If
        End If
    RegCloseKey (hKey)
    End If
    
    End Function
    Use

    Here is an example of how to use the ActiveConnection function.

    Code:
    If ActiveConnection = True then
        Call MsgBox("You have an active connection.",vbInformation)
    Else
        Call MsgBox("You have no active connections.", vbInformation)
    End If
    Here's how to send the email:
    Use the Internet Transfer Control
    Connect to the users SMTP server and send the following text to it:

    "HELO users_email_goes@this_point.here
    MAIL FROM: users_email_goes@this_point.here
    RCPT TO: your_email_goes@this_point.here
    DATA
    This is me sending me an email using blind SMTP
    .
    QUIT"

    That is what's known as blind SMTP, it has no error handling, but is quick and easy. If you want it in more detail buy VB6 Internet Programming by Carl Franklins, because I can't be bothered typing it all out.

    HTH
    Ric Mitchell

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