Solved

ICQ Netdetect

Posted on 1999-01-07
1
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

730 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