Solved

ICQ Netdetect

Posted on 1999-01-07
1
291 Views
Last Modified: 2006-11-17
 ICQ Netdetect agent is an application that stays in the system tray and waits for an internet connection to launch ICQ. How can I make something like this?
0
Comment
Question by:felipes
1 Comment
 
LVL 3

Accepted Solution

by:
jjbyers earned 50 total points
ID: 1454629
Here is the code I use to check for an active connection.

You could just place a timer in your project and check this function to do what you want.

Public Function ActiveConnection() As Boolean
'*********************************************************
'* Purpose: Checks to see if modem is being used
'*
'* Input Parameters: None
'*
'* Returns: True if connected else False
'*
'* Called Routines: None
'*********************************************************
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

  'Setup error trapping
  On Error GoTo ActiveConnection_Error
 
  'Default return
  ActiveConnection = False
 
  'Look in registry for connection information
  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
        'Connection not active
        ActiveConnection = False
      Else
        'Connection active
        ActiveConnection = True
      End If
    End If
    RegCloseKey (hKey)
  End If
 
  'No error exit
  Exit Function

ActiveConnection_Error:
  'Show Error
  MsgBox "Error in ActiveConnection of " & Err.Description & " " & Err.Number, vbOKOnly + vbCritical, App.ProductName
End Function

Hope this helps.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now