Results 1 to 6 of 6

Thread: Does anyone know how I can detect a network connection.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    25
    I need to detect whether or not I currently have a network connection. I am on a LAN not a dialup.

    Any solutions...

  2. #2
    Addicted Member dmr's Avatar
    Join Date
    Jul 2000
    Location
    West-Germany :) Timezone: GMT +1 [DST] North.......: 52° 16’ 09” East...: 10° 31’ 16”
    Posts
    255
    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!

  3. #3
    Stryker
    Guest

    Wink 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

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    25
    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

  5. #5
    daugman
    Guest
    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
    );

  6. #6
    daugman
    Guest
    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
  •  



Click Here to Expand Forum to Full Width