Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 6 - Retrieving Networking Configuration Inform...
Moblin
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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

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


    (Page 6 of 6 )

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

    Public Function getProxyStructure() As DataTable
            Dim dt As New DataTable
            dt.Columns.Add(New DataColumn("Description"))
            dt.Columns.Add(New DataColumn("ProxyPortNumber"))
            dt.Columns.Add(New DataColumn("ProxyServer"))
            dt.Columns.Add(New DataColumn("ServerName"))
            Return dt
        End Function   

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

        Public Sub addProxy(ByRef dt As DataTable, ByVal Description As String, ByVal ProxyPortNumber As String, ByVal ProxyServer As String, ByVal ServerName As String)
            Dim dr As DataRow
            dr = dt.NewRow
            dr("Description") = Description
            dr("ProxyPortNumber") = ProxyPortNumber
            dr("ProxyServer") = ProxyServer
            dr("ServerName") = ServerName
            dt.Rows.Add(dr)
        End Sub

    Once you have created the wrapper, the following VB.NET code should support it with some minimum information of “WinProxies” 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_Proxy")
                Dim dt As DataTable = globals.getNetworkClientStructure
                For Each queryObj As ManagementObject In searcher.Get()
                    Console.WriteLine("Description: {0}", queryObj("Description"))
                    Console.WriteLine("ProxyPortNumber: {0}", queryObj("ProxyPortNumber"))
                    Console.WriteLine("ProxyServer: {0}", queryObj("ProxyServer"))
                    Console.WriteLine("ServerName: {0}", queryObj("ServerName"))
                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_Proxy",,48)
    For Each objItem in colItems
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "ProxyPortNumber: " & objItem.ProxyPortNumber
        Wscript.Echo "ProxyServer: " & objItem.ProxyServer
        Wscript.Echo "ServerName: " & objItem.ServerName
    Next

    Any comments, suggestions, bugs, errors, feedback etc. are highly appreciated at jag_chat@yahoo.com.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · [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

    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...
    - Creating and Drawing a Game Map in VB.NET
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway