?
Solved

ICQ Netdetect

Posted on 1999-01-07
1
Medium Priority
?
309 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 100 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

839 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