Wrox Programmer Forums
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 7th, 2006, 04:24 PM
2V. 2V. is offline
Authorized User
 
Join Date: Aug 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default my IP adr.

How to get IP address (using C#) of my computer that situated in Local Area Network, that use 1 workGroup (NO DNS and other such services) and how can I take IP addresses or HostNames of other computers that work in this networks too.

 
Old August 14th, 2006, 04:05 PM
Registered User
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 public string[] getUserandHostDetails()
        {
            string[] result = new string[5];
            result[0] = Dns.GetHostName().ToString(); //ComputerName;
            result[1] = GetIPAddress().ToString(); //IP Address;
            result[2] = WindowsIdentity.GetCurrent().Name.ToString(); //UserName
            result[3] = TimeZone.CurrentTimeZone.StandardName; //TimeZone

            return result;
        }
        private string GetIPAddress()
        {
            string strHostName = System.Net.Dns.GetHostName();
            IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
            IPAddress[] addr = ipEntry.AddressList;

            for (int i = 0; i < addr.Length; i++)
            {
                return addr[i].ToString();
            }
            return "0";

        }






Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me i must Get IP Address pla_2 C# 2005 2 October 12th, 2006 07:51 AM
TCP/IP HELP jpsultana VB.NET 2002/2003 Basics 0 September 29th, 2005 01:37 PM
IP mani_he Beginning PHP 4 November 8th, 2004 09:53 PM
get hostname from IP cygnusx04 Classic ASP Basics 12 October 14th, 2004 02:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.