Solved

ICQ NetDetect

Posted on 1999-01-08
4
277 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
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

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

Title # Comments Views Activity
Controlling which port to download from 4 71
Best way to parse out a json string in VB6? 10 111
Adding to a VBA? 6 61
Problem to With line 4 39
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…
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…
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…

912 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

22 Experts available now in Live!

Get 1:1 Help Now