473,385 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

HELP - enumerating local NICS

LK
Can PLEASE SOMEONE HELP me how to enumerate local network interfaces (i.e ip
addresses, dns, etc.) with csharp.

I need the type of information that would come up when typing

ipconfig /all

at a command prompt.

Thank you soo much
Jul 21 '05 #1
3 1500
LK wrote:
Can PLEASE SOMEONE HELP me how to enumerate local network interfaces (i.e ip
addresses, dns, etc.) with csharp.

I need the type of information that would come up when typing

ipconfig /all

at a command prompt.

Thank you soo much


You could use WMI. Try the following (remember to reference
System.Messaging.dll):

using System;
using System.Management;

public class App
{
public static void Main()
{
ManagementObjectSearcher mos =
new ManagementObjectSearcher("select * from
Win32_NetworkAdapterConfiguration");
ManagementObjectCollection adapters = mos.Get();
foreach(ManagementObject adapter in adapters)
{
String[] ipAddresses = (String[])adapter["IPAddress"];
foreach(String ipAddress in ipAddresses)
Console.WriteLine(ipAddress);
}
}
}

Check out [1] for information about the
Win32_NetworkAdapterConfiguration WMI Class.

/Joakim

[1]
http://msdn.microsoft.com/library/de...figuration.asp
Jul 21 '05 #2
LK
Oh, thank you soo much, just what I needed. I suppose that there is nothing
under System.Net that I could use. Just one more question, what does this
mean, and do I have to worry about it when distributing the app to the
general population. Thank you soo much

"The class is not guaranteed to be supported after the ratification of the
Distributed Management Task Force (DMTF) CIM network specification."

"Joakim Karlsson" <jk*******@NOSPAMjkarlsson.com> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
LK wrote:
Can PLEASE SOMEONE HELP me how to enumerate local network interfaces (i.e
ip
addresses, dns, etc.) with csharp.

I need the type of information that would come up when typing

ipconfig /all

at a command prompt.

Thank you soo much


You could use WMI. Try the following (remember to reference
System.Messaging.dll):

using System;
using System.Management;

public class App
{
public static void Main()
{
ManagementObjectSearcher mos =
new ManagementObjectSearcher("select * from
Win32_NetworkAdapterConfiguration");
ManagementObjectCollection adapters = mos.Get();
foreach(ManagementObject adapter in adapters)
{
String[] ipAddresses = (String[])adapter["IPAddress"];
foreach(String ipAddress in ipAddresses)
Console.WriteLine(ipAddress);
}
}
}

Check out [1] for information about the
Win32_NetworkAdapterConfiguration WMI Class.

/Joakim

[1]
http://msdn.microsoft.com/library/de...figuration.asp

Jul 21 '05 #3
LK wrote:
Oh, thank you soo much, just what I needed. I suppose that there is nothing
under System.Net that I could use. Just one more question, what does this
mean, and do I have to worry about it when distributing the app to the
general population. Thank you soo much
The target OS must have WMI installed in order for the System.Management
assembly to work. It is installed by default on Windows 2000 and Windows
ME and later. For Windows 95/98 you can download it here [1].

"The class is not guaranteed to be supported after the ratification of the
Distributed Management Task Force (DMTF) CIM network specification."


I hadn't noticed that comment myself! From what I can see this means
that the schema of this class is subject to change, but there will be
something similar available in the future.

/Joakim

[1]
http://www.microsoft.com/downloads/d...displaylang=en
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Arne | last post by:
Hi, Probably an easy answer to this, but I have not been able to figure it out. How can I find the IP-address of the machine that my Java-program is running on ? Could not find any methods in...
7
by: Rohan Ranade | last post by:
I am trying to implement a crawler in C# that scans all the shared folders in remote computers in a windows network. Are there classes in .NET to do this directly? Please help. Thank You. Rohan
1
by: Peter Steele | last post by:
I want to build a list of the NICs on a system along with their IPs and netmasks. What's the easiest way to do this?
2
by: Tony | last post by:
I have this problem - I have a hashtable, containing a list of filenames. Every 60 seconds, I have a thread that enumerates thru this hashtable, and based on some simple logic, some of the items...
1
by: Mark Hollander | last post by:
Hi All, Could you please help me convert this code so that it will run in VB.NET Thank You Mark Hollander Private Type USER_INFO Name As String
1
by: Phil Galey | last post by:
Is there any way of enumerating all printers, including network printers in VB.NET? printing.PrinterSettings.InstalledPrinters only enumerates printers attached to the local workstation. ...
3
by: LK | last post by:
Can PLEASE SOMEONE HELP me how to enumerate local network interfaces (i.e ip addresses, dns, etc.) with csharp. I need the type of information that would come up when typing ipconfig /all ...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
3
by: rhaazy | last post by:
I am working on a server/client application where the client scans a computer for all available mac addresses and stores the information in a database, associating mac addresses to assets. I see...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.