Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 5 - Retrieving Networking Configuration Inform...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Retrieving Networking Configuration Information Using Visual Basic.NET and VBScript
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    2006-01-11

    Table of Contents:
  • Retrieving Networking Configuration Information Using Visual Basic.NET and VBScript
  • How to List all IPAddresses of a computer using Visual Basic.NET – the code
  • How to retrieve MAC address and other miscellaneous network information using Visual Basic.NET – preparing the wrapper
  • How to retrieve MAC address and other miscellaneous network information using Visual Basic.NET – the code
  • How to retrieve Network Client Information using Visual Basic.NET
  • How to retrieve Win Proxy Information using Visual Basic.NET

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Retrieving Networking Configuration Information Using Visual Basic.NET and VBScript - How to retrieve Network Client Information using Visual Basic.NET


    (Page 5 of 6 )

    Before getting the information on “Network Clients” installed on your computer, we need to create a wrapper to store the same information.  Let us proceed with creating a wrapper:

     Public Function getNetworkClientStructure() As DataTable
            Dim dt As New DataTable
            dt.Columns.Add(New DataColumn("Caption"))
            dt.Columns.Add(New DataColumn("Description"))
            dt.Columns.Add(New DataColumn("InstallDate"))
            dt.Columns.Add(New DataColumn("Manufacturer"))
            dt.Columns.Add(New DataColumn("Name"))
            Return dt
        End Function

    The following method “addNetworkClient” adds a single row based on the structure you create for the data table using the above method.

        Public Sub addNetworkClient(ByRef dt As DataTable, ByVal Caption As String, ByVal Description As String, ByVal InstallDate As String, ByVal Manufacturer As String, ByVal Name As String)
            Dim dr As DataRow
            dr = dt.NewRow
            dr("Caption") = Caption
            dr("Description") = Description
            dr("InstallDate") = InstallDate
            dr("Manufacturer") = Manufacturer
            dr("Name") = Name
            dt.Rows.Add(dr)
        End Sub

    Once you complete the creation of wrapper, the following VB.NET code should support it with some minimum information of “NetworkClients” available on your system.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     
            Try
                Dim searcher As New ManagementObjectSearcher( _
                    "root\CIMV2", _
                    "SELECT * FROM Win32_NetworkClient")
                Dim dt As DataTable = globals.getNetworkClientStructure
                For Each queryObj As ManagementObject In searcher.Get()
    globals.addNetworkClient(dt, queryObj("Caption"), queryObj("Description"), queryObj("InstallDate"), queryObj("Manufacturer"), queryObj("Name"))
                Next
                Me.DataGrid1.DataSource = dt
            Catch err As Exception
                MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
            End Try
     
        End Sub

    You can achieve the same thing with VBScript as follows:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService.ExecQuery( _
        "SELECT * FROM Win32_NetworkClient",,48)
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "InstallDate: " & objItem.InstallDate
        Wscript.Echo "Manufacturer: " & objItem.Manufacturer
        Wscript.Echo "Name: " & objItem.Name
    Next

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · [i]This article explains how to retrieve “Network settings” information dynamically...
       · This is a very good article, but a little insight on adding a reference for...
       · Hello,Actually, within the same article I already added the following...
     

    VISUAL BASIC.NET ARTICLES

    - User-defined Functions using Visual Basic Ap...
    - Understanding Object Binding in VBA
    - Mastering the Message Box
    - Testing a Windows Forms Application
    - Using Visual Basic.NET Features to Code a Wi...
    - Correcting Code in a Windows Forms Applicati...
    - Write Readable Code and Comments for Windows...
    - How to Code and Test a Windows Forms Applica...
    - Adding Features to a Windows Forms Applicati...
    - How to Design a Windows Forms Application
    - LINQ to XML Programming Using Visual Basic.N...
    - Understanding Delegates using Visual Basic.N...
    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    Stay green...Green IT