|
-
Apr 8th, 2001, 05:12 PM
#1
Thread Starter
Junior Member
I need to detect whether or not I currently have a network connection. I am on a LAN not a dialup.
Any solutions...
-
Apr 8th, 2001, 07:41 PM
#2
Addicted Member
When you are not directly connected to the internet you can't detect if you are. You could try to ping a site and when you get an answer you're connected but I don't see direct way.
Or you install a server-application on the server which sends you the current connectionstate via LAN to a client-app... 
Or do you just want to know if you have an active LAN-Connection?
Code that I author is neither elegant nor efficient. It is, however, functional. Once I get something that works, I'm generally satisfied with myself - I mean, if it works, that's good enough, right?
Originally posted by aknisely
Sorry, but I feel uncomfortable on CC with clothes on
__________________
The truth ... is out there!
-
Apr 8th, 2001, 07:56 PM
#3
For detecting internet via LAN?
For info on how to determine if your internet connection is via a LAN, take a look in the Previous Topic.
To detect if you are on a LAN with no internet connection, well ... I'll get back
-
Apr 16th, 2001, 07:41 PM
#4
Thread Starter
Junior Member
Thanx for the input Stryker. Worked great.
If you come up with how to detect a LAN without an internet connection I'd be very interested
-
Apr 16th, 2001, 09:28 PM
#5
Just try and find another computer on the LAN (or a known server).
That's what we do for our VB/ASP app... I try and map to the server, and if it's not available -- it'll tell me...
I'll see if I can find the code and post tomorrow. It's part of the WNetOpenEnum API - one of the errors will return is ERROR_NO_NETWORK.
I don't have the VB code handy but :
Code:
DWORD WNetOpenEnum(
DWORD dwScope, // scope of enumeration
DWORD dwType, // resource types to list
DWORD dwUsage, // resource usage to list
LPNETRESOURCE lpNetResource,
// pointer to resource structure
LPHANDLE lphEnum // pointer to enumeration handle buffer
);
-
Apr 17th, 2001, 06:41 AM
#6
Ah ha! I found it :P
Code:
Public Sub ListDomainComputers(p_strDomain As String, p_colUse As Collection)
Dim tNetRes As NETRES2
Dim lngRet As Long
Dim lngHndEnum As Long
On Error Resume Next
With tNetRes
.lpRemoteName = p_strDomain
.dwDisplayType = 1
End With
lngRet = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, 0, tNetRes, lngHndEnum)
If lngRet <> 0 Then ' check for ERROR_NO_NETWORK here!!!
MsgBox "Error getting computers on the LAN.", vbCritical, "Error"
Exit Sub
End If
.
.
.
This will tell you if the network if available or not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|