Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:
I will give a situation to explain my question;
We have so many wifi router in our school. The school have so many building. So each room have a wifi router. Every students have a pc , i want to make a "Positioning System" in our school by taking wifi router's id. I am going to make a database that contains information about Rooters(Which rooter is in which room). Later on i will get information from one of the PCs about it's connection with rooter.after that i will compare that info with the database. So i wil be able to get his location. So for making all of this thing I have to get wifi router info especially router id and name. The question is "how can get wifi router info with c#"
Posted
Comments
CHill60 6-May-15 8:01am    

1 solution

I'd read this MSDN example[^] to start with:
C#
public static void ShowNetworkInterfaces()
{
    IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
    NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
    Console.WriteLine("Interface information for {0}.{1}     ",
            computerProperties.HostName, computerProperties.DomainName);
    if (nics == null || nics.Length < 1)
    {
        Console.WriteLine("  No network interfaces found.");
        return;
    }

    Console.WriteLine("  Number of interfaces .................... : {0}", nics.Length);
    foreach (NetworkInterface adapter in nics)
    {
        IPInterfaceProperties properties = adapter.GetIPProperties();
        Console.WriteLine();
        Console.WriteLine(adapter.Description);
        Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length,'='));
        Console.WriteLine("  Interface type .......................... : {0}", adapter.NetworkInterfaceType);
        Console.WriteLine("  Physical Address ........................ : {0}", 
                   adapter.GetPhysicalAddress().ToString());
        Console.WriteLine("  Operational status ...................... : {0}", 
            adapter.OperationalStatus);
        string versions ="";

        // Create a display string for the supported IP versions. 
        if (adapter.Supports(NetworkInterfaceComponent.IPv4))
        {
             versions = "IPv4";
         }
        if (adapter.Supports(NetworkInterfaceComponent.IPv6))
        {
            if (versions.Length > 0)
            {
                versions += " ";
             }
            versions += "IPv6";
        }
        Console.WriteLine("  IP version .............................. : {0}", versions);
        ShowIPAddresses(properties);

        // The following information is not useful for loopback adapters. 
        if (adapter.NetworkInterfaceType == NetworkInterfaceType.Loopback)
        {
            continue;
        }
        Console.WriteLine("  DNS suffix .............................. : {0}", 
            properties.DnsSuffix);

        string label;
        if (adapter.Supports(NetworkInterfaceComponent.IPv4))
        {
            IPv4InterfaceProperties ipv4 = properties.GetIPv4Properties();
            Console.WriteLine("  MTU...................................... : {0}", ipv4.Mtu);
            if (ipv4.UsesWins)
            {

                IPAddressCollection winsServers = properties.WinsServersAddresses;
                if (winsServers.Count > 0)
                {
                    label = "  WINS Servers ............................ :";
                    ShowIPAddresses(label, winsServers);
                }
            }
        }

        Console.WriteLine("  DNS enabled ............................. : {0}", 
            properties.IsDnsEnabled);
        Console.WriteLine("  Dynamically configured DNS .............. : {0}", 
            properties.IsDynamicDnsEnabled);
        Console.WriteLine("  Receive Only ............................ : {0}", 
            adapter.IsReceiveOnly);
        Console.WriteLine("  Multicast ............................... : {0}", 
            adapter.SupportsMulticast);
        ShowInterfaceStatistics(adapter);

        Console.WriteLine();
    }
 
Share this answer
 
v2
Comments
Emin ATEŞ 7-May-15 14:01pm    
I tried this MSDN example but it doesn't give a specific info for wireless router. it gave same result for each router. I think the solution(MSDN example) doesn't contain router ID or name. It gives info about wifi connection.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900