2011-01-24 20 views

Respuesta

18

Tener un vistazo a esto: link

y esto: link

textBox1.Text = "Computer Name: " + Environment.MachineName 

textBox2.Text = "IP Add: " + Dns.GetHostAddresses(Environment.MachineName)[0].ToString(); 
+0

Gracias. Funcionó bien – Holyoxx

+0

NP me alegro de poder ayudar – Rye

+0

obtener la dirección de su propia máquina es pasible, ¿cómo obtener la dirección IP de otra máquina, mientras que inician sesión en nuestra aplicación? –

3

Comprobar más: How To Get IP Address Of A Machine

System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal; 


string strName = p.Identity.Name; 


To get the machine name, 


System.Environment.MachineName 
or 
using System.Net; 
strHostName = DNS.GetHostName(); 


// Then using host name, get the IP address list.. 
IPHostEntry ipEntry = DNS.GetHostByName (strHostName); 
IPAddress [] addr = ipEntry.AddressList; 

for (int i = 0; i < addr.Length; i++) 
{ 
Console.WriteLine ("IP Address {0}: {1} ", i, addr[i].ToString()); 
} 
0

En forma fácil ..

string IP_Address = Dns.GetHostByName(Environment.MachineName).AddressList[0].toString(); 
Cuestiones relacionadas