shefy
shefy

Reputation: 51

Class in c# which gives the information about the machine

I want to get the information about the the machine configuration i.e like ip address of the machine

Upvotes: 4

Views: 494

Answers (8)

Hans Olsson
Hans Olsson

Reputation: 55039

You can use System.Net.Dns to get out stuff like hostname and IP Address(es). But you might need to use other classes for other information.

http://msdn.microsoft.com/en-us/library/system.net.dns.aspx

Upvotes: 0

David Neale
David Neale

Reputation: 17038

The Environment class will get some detail about the machine name, logged on user etc. You can use get the IP Address from that:

 System.Net.Dns.GetHostByName(Environment.MachineName);

Or just use:

System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName());

Upvotes: 1

Jibu P C_Adoor
Jibu P C_Adoor

Reputation: 3364

Dns Class

I think the below link will help you in the above context

http://msdn.microsoft.com/en-us/library/system.net.dns.aspx

Upvotes: 0

Hans Passant
Hans Passant

Reputation: 942010

For general machine information, you'll want to use WMI. It is supported by the classes in the System.Management namespace, in particular the ManagementQuery class.

The best way to get started on this is the WmiCodeCreator utility. It lets you discover what WMI classes are available on the machine and run queries. Best of all, it auto-generates the C# code you need, ready to cut-and-paste into your program. Strongly recommended.

Upvotes: 3

Alex Pacurar
Alex Pacurar

Reputation: 5861

you may use Dns for ip/host information and Environment for generic system information (os, version)

Upvotes: 6

tanascius
tanascius

Reputation: 53944

Have a look at Sytem.Environment, too, though it will not tell your the ip address. But you can find:

  • MachineName
  • UserName
  • OSVersion
  • ...

For an IP look at the Dns-class, as klausbyskov or Andrey suggested.

Upvotes: 2

Andrey
Andrey

Reputation: 60075

Dns.GetHostAddresses("localhost");

Upvotes: 0

Klaus Byskov Pedersen
Klaus Byskov Pedersen

Reputation: 120997

Have a look at the Dns class.

Upvotes: 0

Related Questions