Solved

ICQ NetDetect

Posted on 1999-01-08
4
290 Views
Last Modified: 2010-08-05
 ICQ (I Seek You) have a program called NetDetect that stays in the system tray until a internet connection is detected. When this happens, it closes itself and launch ICQ main program.
  My question is: To implement the same funcionality of NetDetect I should keep checking for internet connection (via wininet API) or there is a more efficient way to do 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
4 Comments
 
LVL 5

Expert Comment

by:thegilb
ID: 1454843
The only way I can think of doing this is having a timer... I mean - NetDetect I think works the same way by just sticking a timer up and giving it a delay of 5000 I think... Not too sure... Give the timer a try and lemme know how it goes...
0
 

Expert Comment

by:edunc
ID: 1454844
i don't have an answer to your question, but can you give me your code of how you check for an internet connection?  my email is unc69jz@hotpop.com   thanks.
0
 
LVL 3

Accepted Solution

by:
Michelt earned 50 total points
ID: 1454845
Add this code to the module:

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

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

Add this code to the form:

Private Sub check_connect()
If ActiveConnection = True Then
  check_connect = true
Else
   check_connect = false
End If
End Sub

Private sub Formload
 pause
end sub

Private Sub Pause()

Dim PauseTime, Start, Finish, TotalTime
Dim bConnect as boolean

Do While bconnect = False
    xtim = xtim + 1
    PauseTime = 5
    Start = Timer
    Do While Timer < Start + PauseTime
       DoEvents
    Loop
    Finish = Timer
    TotalTime = Finish - Start
    bconnect = check_connect
loop

end sub

If you have problems using the code the please e-mail me.

0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1454846
Bought This Question.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
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…

695 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