Click here to Skip to main content
15,392,442 members
Articles / Programming Languages / C# 3.5
Posted 2 Apr 2015


20 bookmarked

Geolocation wifi Scanner and Finder

Rate me:
Please Sign up or sign in to vote.
5.00/5 (9 votes)
2 Apr 2015CPOL2 min read
Written in C# and VS2010 as a class libary to be used in your own project.


The project scans wifi networks in the area to retrieve names, speeds and MAC addresses that can then be used to make a geo-location request to Google's servers and was written using C# in VS2010 to produce a class library.

A service is provided to poll for new wifi connects every ten seconds or so and these connections are returned in a collection ready to be used as you like or saved as an XML table by calling Save(XMLFileName); so that the data can be used by other programs.


I was concerned with just what Google was uploading when someone in the area made a geo-location request and how my data was being used plus I wanted to build geo-location into the browser I have been working on.

Using the Code

Included is the full source code for the project along with output class library that has been compiled as a DLL and all the calls to the library use static methods as shown below to make the code simple to use. Sample code is provided in the file Sample.cs.

Full credit given to NativeWifi who produces some of the open source Windows API calls used in the project .

WifiScanner.WifiConnection.Start(10000);//Poll wifi connections every ten seconds
Thread.Sleep(30000);                    //Wait for three polls to complete
WifiScanner.WifiConnection.Stop();      //stop polling for new connections
string Json=WifiScanner.WifiConnection.GetGeoLocation(); //Ask Google for the json string
WifiScanner.WifiConnection.Clear();     //Clear any internal data

Viewing the request sent to Google from your browser is not easy since it uses encrypted SSL packets but a little trick that works in Firefox is to type "About:config" into the URL and then search for "Google" and to then edit the Geo.Wifi.Url value from being HTTPS to HTTP and to then make a geo-location request from the browser that uses a proxy server that allows you to inspect the outbound HTTP request header and XML post data.

POST /geolocation/v1/geolocate?key=abcdFakeKey HTTP/1.1
Connection: keep-alive
Content-Length: 662
Pragma: no-cache
Cache-Control: no-cache
Content-Type: application/json
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Accept-Encoding: gzip, deflate


This is my first project that I have released on CodeProject but keep watching if you want a fully working remote desktop or want to learn how to get "Play to" working in Windows without having to open lots of ports or to have all the correct Windows services running.



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


About the Author

Dr Gadgit
United Kingdom United Kingdom
Old dog that is tired of learning new tricks when the new dish they are cooking never tastes quite so good as the old one.

Comments and Discussions

QuestionAccuracy Pin
Tom Ragsdale317-Jul-19 1:53
MemberTom Ragsdale317-Jul-19 1:53 
Questiongood work Pin
Jhone Menezes10-Mar-17 20:04
MemberJhone Menezes10-Mar-17 20:04 
GeneralMy vote of 5 Pin
D V L6-Nov-15 22:53
professionalD V L6-Nov-15 22:53 
Questionverified Pin
ARCHARRY3-Apr-15 9:31
MemberARCHARRY3-Apr-15 9:31 
QuestionBattery Drain Pin
Vasudevan Deepak Kumar3-Apr-15 2:38
MemberVasudevan Deepak Kumar3-Apr-15 2:38 
AnswerRe: Battery Drain Pin
Dr Gadgit5-Apr-15 8:39
MemberDr Gadgit5-Apr-15 8:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.