Solved

ICQ NetDetect

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

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now