Solved

ICQ Netdetect

Posted on 1999-01-07
1
285 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

708 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

16 Experts available now in Live!

Get 1:1 Help Now