-
Apr 17th, 2013, 04:01 AM
#1
Thread Starter
Lively Member
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,
-
Apr 17th, 2013, 04:34 AM
#2
Thread Starter
Lively Member
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,
-
Apr 17th, 2013, 10:17 AM
#3
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
-
Apr 17th, 2013, 11:28 AM
#4
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.
-
Apr 18th, 2013, 05:14 AM
#5
Thread Starter
Lively Member
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,
-
Apr 18th, 2013, 06:12 AM
#6
Re: How to Check the internet connections adapters list?
The GetIfTable function may return the desired information.
-
Apr 18th, 2013, 09:22 AM
#7
Re: How to Check the internet connections adapters list?
Originally Posted by green.pitch
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|