Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8709587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:23:53+00:00 2026-06-13T04:23:53+00:00

I have a C# function which return Local IP Address. private string GetLocalIPByHostName() {

  • 0

I have a C# function which return Local IP Address.

private string GetLocalIPByHostName()
    {
        string host = Dns.GetHostName();
        string LocalIP = string.Empty;
        IPHostEntry ip = Dns.GetHostEntry(host);
        foreach (IPAddress _IPAddress in ip.AddressList)
        {
            if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
            {
                LocalIP = _IPAddress.ToString();

            }
        }
        return LocalIP;
    }

By using this local IP address, I tried to get MAC Address.

protected string GetMACAddressByIP(string ip)
    {
        try
        {
            ManagementObjectSearcher query= new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection queryCollection = query.Get();
            bool Found = false;
            foreach(ManagementObject _ManagementObject in queryCollection)
            {
                if (_ManagementObject["IPAddress"] != null)
                {
                    string _IPAddress;
                    _IPAddress = string.Join(".", (string[])_ManagementObject["IPAddress"]);

                    if(!_IPAddress.Equals(""))
                    {
                        if(_IPAddress.Equals(ip.Trim()))
                        {
                                Found = true;
                        }
                    }

                    if(Found == true)
                    {
                        if (_ManagementObject["macaddress"] != null)
                        {
                            if (!_ManagementObject["macaddress"].Equals(""))
                            {
                                return (string)_ManagementObject["macaddress"];
                            }
                        }
                    }
                    else
                    {
                        Found = false;
                    }
                }
            }

            MessageBox.Show("No Mac Address Found");
            return "";
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.Message);
            return "";
        }
    }

Two of the functions work correctly.
But what I would like to do is getting other PC’s IP Address at the same LAN network.
Then, If I get those IP Addresses , that will be input value to my

GetMACAddressByIP(string ip)

function.

But my problem is I don’t know how to get other pc IP Address.

private List<string> GetRemoteIPs(string LocalIPAddress)
    {
        List<string> RemoteIPs = new List<string>();

             /*** Here code will be as suggestion of yours.  ****/    

        return RemoteIPs;
    }

Then, Next Question is
Is this possible to get MAC Address of PC which is already turn off ?

Every solution will be really appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:23:54+00:00Added an answer on June 13, 2026 at 4:23 am
        // Get all active IP connections on the network
        private void btnSearch_Click(object sender, EventArgs e)
        {
            System.Net.NetworkInformation.IPGlobalProperties network = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();
            System.Net.NetworkInformation.TcpConnectionInformation[] connections = network.GetActiveTcpConnections();
    
            foreach (System.Net.NetworkInformation.TcpConnectionInformation connection in connections)
            {
    
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function which returns a datatype InetAddress[] public InetAddress [] lookupAllHostAddr(String host)
Can I´m asking for advice. I have function which should return javascript object function
I have a controller function which return a response with a value, and I
hi i have function which is called by tinker listbox so i cannot return
I have a function which returns 3 numbers, e.g.: def numbers(): return 1,2,3 usually
I have a function in which I hope to return different type -(UIButton *)returnObject1
I have a function to create a pdf which should return bitarray. Below is
I have a java code which gets the function names, their return types, their
I have a function in which I make use of a local array. I
I have a function which contains a constructor: declare function local:Construct ($id) { <tag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.