Results 1 to 7 of 7

Thread: How to Check the internet connections adapters list?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    How to Check the internet connections adapters list?

    Hello
    I have 2 internet connection on my pc, where one is broad-band connection "Local Area Connection" and another is a dial-up connection "Idea Internet".

    Now here I want to get the list of all the connection adapters. Along with that want to get which is the Active i mean which is being used.

    I searched in google but din't found any proper solution instead of "InternetGetConnectedStateEx" API which only shows if the internet is Active or Disabled.

    Is it possible in VB6.0 to get lists of all Internet Connections Adapters with ther Active status?

    Thanks in advace,
    with warm Regards,

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    Re: How to Check the internet connections adapters list?

    Greetings,
    Sorry for the duel posting, however I'v got few WMI concepts to get Network Connection's ID Lists..

    Code:
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = 1")
    
    For Each objItem In colItems
        Msgbox "Caption: " & objItem.Caption & vbNewLine & "Description: " & objItem.Description
    Next
    It's working but the output is something like:
    Caption: [00000007] Realtek RTL8139/810x Family Fast Ethernet NIC
    Description: Realtek RTL8139/810x Family Fast Ethernet NIC


    It's not showing "Local Area Connection" Or "Idea Internet". Am I missing any Property?

    Thanks
    Regards,

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: How to Check the internet connections adapters list?

    Thread moved from the 'CodeBank VB6' forum (which is for you to post working code examples, not questions) to the 'VB6 and earlier' forum

  4. #4
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    Re: How to Check the internet connections adapters list?

    Getting a list of adapters will vary with the operating system. Also be aware that the list will not be in the same order every time you boot up. If you want to save a selection, you must save the CLSID, as it is the only static element. The following code uses a Command Button called "cmdLoad" and a ListBox called "List1".

    J.A. Coutts
    Code:
    Option Explicit
    
    Private Const ADAPTER_NAME_SIZE          As Long = 256
    Private Const ADAPTER_LIST_SIZE          As Long = 32
    Private Const ETHER_ADDR_LENGTH          As Long = 6
    Private Const MAX_PATH                   As Long = 260
    Private Const VER_PLATFORM_WIN32_NT      As Long = 2
    Private AdList          As TCP_AdapterList
    Private nHandle         As Long
    
    Private Type OSVERSIONINFO
        dwOSVersionInfoSize As Long
        dwMajorVersion      As Long
        dwMinorVersion      As Long
        dwBuildNumber       As Long
        dwPlatformId        As Long
        szCSDVersion        As String * 128 ' Maintenance string for PSS usage
    End Type
    
    Private Type TCP_AdapterList
        m_nAdapterCount                             As Long     'Number of adapters
        m_szAdapterNameList(ADAPTER_LIST_SIZE - 1)  As String * ADAPTER_NAME_SIZE 'Array of adapter names
        m_nAdapterHandle(ADAPTER_LIST_SIZE - 1)     As Long     'Array of adapter handles, this are key handles for any adapter relative operation
        m_nAdapterMediumList(ADAPTER_LIST_SIZE - 1) As Long     'List of adapter mediums
        m_czCurrentAddress(ADAPTER_LIST_SIZE - 1)   As String * ETHER_ADDR_LENGTH 'current (configured) ethernet address
        m_usMTU(ADAPTER_LIST_SIZE - 1)              As Integer  'current adapter MTU
    End Type
    
    
    Private Declare Function GetTcpipBoundAdaptersInfo Lib "ndisapi.dll" (ByVal hOpen As Long, ByRef Adapters As TCP_AdapterList) As Boolean
    Private Declare Function IsDriverLoaded Lib "ndisapi.dll" (ByVal hOpen As Long) As Boolean
    Private Declare Function OpenFilterDriver Lib "ndisapi.dll" (ByVal pszFileName As String) As Long
    Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long
    Private Declare Function ConvertWindows2000AdapterName Lib "ndisapi.dll" (ByVal szAdapterName As String, _
                                                           ByVal szUserFriendlyName As String, _
                                                           ByRef dwUserFriendlyNameLength As Long) As Boolean
    Private Declare Function ConvertWindows9xAdapterName Lib "ndisapi.dll" (ByVal szAdapterName As String, _
                                                           ByVal szUserFriendlyName As String, _
                                                           ByRef dwUserFriendlyNameLength As Long) As Boolean
    Private Declare Function ConvertWindowsNTAdapterName Lib "ndisapi.dll" (ByVal szAdapterName As String, _
                                                           ByVal szUserFriendlyName As String, _
                                                           ByRef dwUserFriendlyNameLength As Long) As Boolean
    
    Private Function LoadAdapters() As Boolean
        Dim verInfo         As OSVERSIONINFO
        Dim szFriendlyName  As String
        Dim N%
        ' Allocate string buffer
        szFriendlyName = String$(MAX_PATH * 4, vbNullChar)
        verInfo.dwOSVersionInfoSize = Len(verInfo)
        GetVersionEx verInfo
        'Clear ListBox
        List1.Clear
        For N% = 0 To AdList.m_nAdapterCount - 1
            'Convert internal network interface name to user-friendly one depending of the OS
            If verInfo.dwPlatformId = VER_PLATFORM_WIN32_NT Then
                If verInfo.dwMajorVersion = 5 Or verInfo.dwMajorVersion = 6 Then
                    'Windows 2000/XP or Vista
                    ConvertWindows2000AdapterName AdList.m_szAdapterNameList(N%), szFriendlyName, MAX_PATH * 4
                ElseIf verInfo.dwMajorVersion = 4 Then
                    'Windows NT 4.0
                    ConvertWindowsNTAdapterName AdList.m_szAdapterNameList(N%), szFriendlyName, MAX_PATH * 4
                End If
            Else
                'Windows 9x/ME
                ConvertWindowsNTAdapterName AdList.m_szAdapterNameList(N%), szFriendlyName, MAX_PATH * 4
            End If
            'Load items to ListBox
            List1.AddItem szFriendlyName
        Next N%
    End Function
    
    
    
    Private Sub cmdLoad_Click()
        nHandle = OpenFilterDriver("NDISRD")
        'Check if driver is loaded properly
        If IsDriverLoaded(nHandle) = False Then
            MsgBox "Driver not installed on this system or failed to load."
            Exit Sub
        End If
        'Get TCP/IP bound adapters information
        GetTcpipBoundAdaptersInfo nHandle, AdList
        Call LoadAdapters
    End Sub
    EDIT: I forgot to mention that this routine uses the NDISRD.sys driver from http://www.ntkernel.com/. The same information is available directly from the registry, but it is scattered all over the place. This driver hooks the Microsoft NDIS driver and collects all the information in one place.
    Last edited by couttsj; Apr 17th, 2013 at 12:11 PM.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    Re: How to Check the internet connections adapters list?

    Hello couttsj,
    Thanks.. After trying your codes I am getting error "File not found ndisapi.dll".
    Ok I'v downloaded "ndisapi.dll" and paste it into system32 folder..
    Now getting another error "Driver not installed on this system or failed to load."


    Thank you so much
    Regards,

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: How to Check the internet connections adapters list?

    The GetIfTable function may return the desired information.

  7. #7
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    Re: How to Check the internet connections adapters list?

    Quote Originally Posted by green.pitch View Post
    Hello couttsj,
    Thanks.. After trying your codes I am getting error "File not found ndisapi.dll".
    Ok I'v downloaded "ndisapi.dll" and paste it into system32 folder..
    Now getting another error "Driver not installed on this system or failed to load."


    Thank you so much
    Regards,
    "NDISAPI.dll" is a helper file used to interface to the actual driver "NDISRD.sys". DLL files do not have to be registered, but driver files must be. Follow the directions on the NTKernel site. If you have a 64 bit operating system, then further directions can be found at:
    http://www.yellowhead.com/packetvb.htm

    J.A. Coutts

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