473,404 Members | 2,137 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,404 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 1501
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.