by Dave Lambert (3 Submissions)
Category: Complete Applications
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating:
(3 Votes)

This is a very small application that makes it obvious when your system has (with or without your knowledge) connected to the Internet. The small on-screen form stays on top when connected but otherwise is quite unobtrusive (sits behind other apps). As it is possible for even commercial applications to connect WITHOUT prompting (they shouldn't but sometimes do), I have found this to be a necessary addition to my desktop. I thought I'd share the little bit of source code I used to create the program. It isn't complex but does use API calls so I've put it in the Intermediate category. Comments/improvements welcome.
Side Effects
Peace of mind.
API DeclarationsPrivate Declare Function InternetGetConnectedState _
Lib "wininet.dll" (ByRef lpdwFlags As Long, _
ByVal dwReserved As Long) As Long
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40