BPSoftware.com
Home   Utilities   Purchase   FAQ   Support   Contact        
Shareware Utilities
 APrintDirect
 AIconExtract
 AFile Attribute Manager
Freeware Utilities
 AddrMon
 AFileSync
 ASysIcon
 B&P Table Utilities
 BPACLer
 BPSNMPMon
 BPSNMPUtil
 CharCount
 Delphi® Components
 MacAddr
Miscellaneous
 BPSoftware Blog
 Purchase Shareware
 Support

 Subscribe!

Thursday, May 25, 2006
Adapter Information Round 2

In an earlier post getting local adapter information via the Internet Protocol Helper (IP Helper) was discussed. The .NET Framework version 2.0 has the System.Net.NetworkInformation namespace that provides access to this information. For this sample I used VB.NET, however I will try some 'blogged' tricks to see if I can get this working in BDS® 2006 and see how it all works out.




Imports System.Net.NetworkInformation
Imports System.Net

Public Sub RetrieveLocalAdapterInformation(ByVal text As TextBox)
Dim interfaces As NetworkInterface() 'NIC
Dim netInterface As NetworkInterface ' adapter
Dim properties As IPInterfaceProperties
Dim address As PhysicalAddress
Dim ip As IPAddress
Dim ipinfo As IPAddressInformation

text.Clear()

If NetworkInterface.GetIsNetworkAvailable Then
interfaces = NetworkInterface.GetAllNetworkInterfaces

If interfaces.GetLength(0) > 0 Then
For Each netInterface In interfaces
properties = netInterface.GetIPProperties


text.AppendText(netInterface.Name & vbCrLf)
text.AppendText("Id: " & netInterface.Id.ToString & vbCrLf)
address = netInterface.GetPhysicalAddress
text.AppendText("MAC Address: " & (Microsoft.VisualBasic.IIf(address.ToString = String.Empty, "None", address.ToString)) & vbCrLf)
For Each ipinfo In properties.UnicastAddresses
text.AppendText("IP: " & ipinfo.Address.ToString & vbCrLf)
Next
For Each ip In properties.DhcpServerAddresses
text.AppendText("DHCP Server: " & ip.ToString & vbCrLf)
Next
For Each ip In properties.DnsAddresses
text.AppendText("DNS Server: " & ip.ToString & vbCrLf)
Next
text.AppendText("Type: " & netInterface.NetworkInterfaceType.ToString & vbCrLf)
text.AppendText("Operational Status: " & netInterface.OperationalStatus.ToString & vbCrLf)
text.AppendText("Speed: " & netInterface.Speed.ToString("N") & " bytes" & vbCrLf)

' XP Only
'text.AppendText("Receive Only: " & netInterface.IsReceiveOnly.ToString & vbCrLf)

' XP Only
'text.AppendText("Support Multicast: " & netInterface.SupportsMulticast.ToString & vbCrLf)


text.AppendText("Support IPv4: " & netInterface.Supports(NetworkInterfaceComponent.IPv4).ToString & vbCrLf)
text.AppendText("Support IPv6: " & netInterface.Supports(NetworkInterfaceComponent.IPv6).ToString & vbCrLf)
text.AppendText("DnsSuffix: " & properties.DnsSuffix.ToString & vbCrLf)
text.AppendText("" & vbCrLf)
Next
End If
End If
End Sub

Labels: , ,

posted by Brad Prendergast at 8:51:00 PM
Comments:
Links to this post:

Create a Link

Recent Posts
 Local Computer Adapter Information
 Event Log (Part 2)
 LINQ CTP (May 2006)
 Event Log (Part 1)
 It is the Concept that Counts
 myCursor Template
 In time for Easter
 ErrorProvider
 Ho Hum
 Where is the registry in .NET?

 Subscribe!


Labels



Archives
 October 2005
 November 2005
 December 2005
 January 2006
 February 2006
 March 2006
 April 2006
 May 2006
 June 2006
 July 2006
 August 2006
 September 2006
 December 2006
 January 2007
 February 2007
 March 2007
 September 2007
 October 2007
 November 2007
 July 2008
 November 2008
Powered by Blogger