A class in C # that gives information about a machine

I want to get information about the configuration of the machine, for example the ip address of the machine.

+4
source share
8 answers

Dns class

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

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

0
source

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

+6
source

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

The best way to get started is with the WmiCodeCreator utility . It lets you know which WMI classes are available on the machine and run queries. Best of all, it automatically generates the C # code you need, ready to be cut and pasted into your program. Highly recommended.

+3
source

Take a look at Sytem.Environment , although it will not provide your IP address. But you can find:

  • Machinename
  • Username
  • OSVersion
  • ...

For IP, take a look at the Dns class, as suggested by Klausbyskov or Andrey.

+2
source

The Environment class will receive detailed information about the machine name, registered user, etc. You can use getting an IP address from that:

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

Or just use:

 System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()); 
+1
source

Check out the Dns class.

0
source
 Dns.GetHostAddresses("localhost"); 
0
source

You can use System.Net.Dns to output things like hostname and IP address (s). But you may need to use other classes for other information.

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

0
source

Source: https://habr.com/ru/post/1310359/


All Articles