locked
How to enuemrate list of availble wireless network device using C# RRS feed

  • Question

  • I am looking for any application which can enuemrate information of all the available wireless adapter in range on Window7.

    I know there is a way to do this using Pinvoke but I am looking for some featur in .net so that I can use it directly, dont need to go for unmanaged code/Pinvoke.

    any sample code or DLL name in .net will help me alot.


    Abhishek

    Friday, December 21, 2012 5:28 PM

Answers

  • Refer following link. You can use System.Management class (WMI) to get available wireless adapter information

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx
    http://blogs.technet.com/b/heyscriptingguy/archive/2007/08/20/how-can-i-tell-if-a-wireless-network-adapter-is-connected-to-the-network.aspx

    Following link should also help you (Change select query)

    http://wiki.lessthandot.com/index.php/VB.Net:_Getting_a_List_of_Networkconnections_on_a_computer


    Gaurav Khanna | Microsoft VB.NET MVP | Microsoft Community Contributor

    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:25 PM
    Friday, December 21, 2012 7:12 PM
  • There is no WIFI support in Microsoft's .Net framework. 

    You need to call the Windows Wireless SDK APIs like WlanScan and WlanGetAvailableNetworkList, or check if someone wrote a wrapper for these APIs. 

    See also

    Use Native WLAN API in managed code



    Visual C++ MVP

    • Marked as answer by abhi41186 Friday, December 21, 2012 10:02 PM
    Friday, December 21, 2012 9:28 PM
  • I have a wrapper class to use native wifi API.

    Do you which API is used to get the IP address of Device..

    Any Sample code will help...


    Abhishek

    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:24 PM
    Friday, December 21, 2012 10:01 PM
  • You mean the current connection? You can get the mac address from WlanQueryInterface then search the physical addresses from NetworkInterface.GetAllNetworkInterfaces. If a match is found, use IPInterfaceProperties.GetIPv4Properties to get the address for IPV4.


    Visual C++ MVP

    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:24 PM
    Friday, December 21, 2012 10:52 PM
  • You can't obtain IP from a network unless you have connected to a network. 

    If you just want to enumerate the available networks, use WlanGetAvailableNetworkList.




    Visual C++ MVP

    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:24 PM
    Friday, December 21, 2012 11:44 PM
  • Oh ok, so how can I make a connection with router or any other wireless device programatically.

    Is there any API for this in C#/C++


    Abhishek

    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:24 PM
    Saturday, December 22, 2012 6:08 AM
    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:24 PM
    Sunday, December 23, 2012 5:54 PM

All replies

  • Refer following link. You can use System.Management class (WMI) to get available wireless adapter information

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx
    http://blogs.technet.com/b/heyscriptingguy/archive/2007/08/20/how-can-i-tell-if-a-wireless-network-adapter-is-connected-to-the-network.aspx

    Following link should also help you (Change select query)

    http://wiki.lessthandot.com/index.php/VB.Net:_Getting_a_List_of_Networkconnections_on_a_computer


    Gaurav Khanna | Microsoft VB.NET MVP | Microsoft Community Contributor

    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:25 PM
    Friday, December 21, 2012 7:12 PM
  • hi Gaurav,

    Thanks for giving some direction to resolve my query..

    from the code it seems like this will help to find out the network adapter present in a system but I am looking for the set of API which can populate the list of network adapter that I can see in my default wireless manager.

    Suppose there is router in a range then how can I get the information about it using .Net.

    See the attached doc for detail


    Abhishek

    Friday, December 21, 2012 8:58 PM
  • There is no WIFI support in Microsoft's .Net framework. 

    You need to call the Windows Wireless SDK APIs like WlanScan and WlanGetAvailableNetworkList, or check if someone wrote a wrapper for these APIs. 

    See also

    Use Native WLAN API in managed code



    Visual C++ MVP

    • Marked as answer by abhi41186 Friday, December 21, 2012 10:02 PM
    Friday, December 21, 2012 9:28 PM
  • I have a wrapper class to use native wifi API.

    Do you which API is used to get the IP address of Device..

    Any Sample code will help...


    Abhishek

    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:24 PM
    Friday, December 21, 2012 10:01 PM
  • You mean the current connection? You can get the mac address from WlanQueryInterface then search the physical addresses from NetworkInterface.GetAllNetworkInterfaces. If a match is found, use IPInterfaceProperties.GetIPv4Properties to get the address for IPV4.


    Visual C++ MVP

    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:24 PM
    Friday, December 21, 2012 10:52 PM
  • Not only the current one but also the one which in a range.

    Like I want to make an application similar to windows 7 wireless manager which can display all available network device and then user can select to any of the one to establish connection.


    Abhishek

    Friday, December 21, 2012 11:04 PM
  • You can't obtain IP from a network unless you have connected to a network. 

    If you just want to enumerate the available networks, use WlanGetAvailableNetworkList.




    Visual C++ MVP

    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:24 PM
    Friday, December 21, 2012 11:44 PM
  • Oh ok, so how can I make a connection with router or any other wireless device programatically.

    Is there any API for this in C#/C++


    Abhishek

    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:24 PM
    Saturday, December 22, 2012 6:08 AM
    • Marked as answer by abhi41186 Wednesday, January 9, 2013 9:24 PM
    Sunday, December 23, 2012 5:54 PM
  • Thanks for the reply but what if I use native wifi to do the same, what is the difference between native wifi and WMI model

    Abhishek

    Wednesday, January 9, 2013 9:26 PM