[.Net DLL] WMLocationInfo - Get your location via CellID/GPS the easy way!

Should I Integrate GPS Support into the DLL??

  • Yes

    Votes: 39 97.5%
  • No

    Votes: 1 2.5%

  • Total voters
    40
Search This thread

DavidTiger

Senior Member
Nov 2, 2008
210
43
Kirkcaldy
[01/2/11] Update v2.1 - Downgraded .net to v2.0 - Should now work with VS2005!
[31/1/11] Update v2 - Now includes GPS Support!
[30/1/11] Update v1 - Initial Release - CellID Only!

I have created this DLL to allow developers to quickly and easily add support for locations. By using CellID and now GPS!

CellID: This way is done by getting looking at the Cell Towers your mobile is connected to.. and then by searching a database of Cell Locations you can work out an approximate location for your Device, Which is usually accurate within 50-100m!

GPS: I'm sure we all know what GPS is and how it works :) Instead of using the Cell Tower location to find your location, It takes the co-ordinates from the GPS to then query an online source to figure out your location, Which is as accurate as GPS can get! If you're outside and not blocked by many buildings it should be as accurate as <5m :D

To download see the attachments 'WMLocationInfo.rar' contains the DLL file only..
If you are unsure how to go about using this DLL, I have included a sample C# application with full source code, This will show you how to get location by both CellID and GPS :)

Please take note of the copyright info below, before downloading and using my DLL and/or Source Codes :cool:

Thanks,
-David!

Copyright © 2011 David Bell / DavidTiger All Rights Reserved.
All Source Code, Compiled exe and DLL files are the copyrighted works of David Bell/DavidTiger.
You may use/redistribute any included samples or files, but you MUST leave credits where due.
You may NOT include this DLL and/or use its function in any commercial products with an intend to make a profit without written permission first!
All compiled DLL/EXE which do not include a source code have been obfuscated
You also may NOT attempt to dissasemble or reverse engineer any compiled obfuscated distributables (exe/dll).
 

Attachments

  • WMLocationInfo.rar
    9.6 KB · Views: 799
Last edited:

oldsap

Senior Member
Apr 4, 2006
1,100
10
oldsap.blogspot.com
hi thanks for the dll file. this is my code in VB:

Code:
    'Setup variables needed throughout the source
    Dim lat As String, lon As String = ""
    Dim street As String, town As String, county As String = ""
    Dim cellid As String, lac As String, mcc As String, mnc As String = ""

    Private Sub GetCellId()
        'Retreive cell tower info from the DLL
        Dim CellTowerInfo As WMCellInfo.CellIDInfo.RILCELLTOWERINFO =   WMCellInfo.CellIDInfo.GetCellTowerInfo()

        'Asign each variable with its cell data
        cellid = CellTowerInfo.CellID.ToString()
        lac = CellTowerInfo.LAC.ToString()
        mcc = CellTowerInfo.MCC.ToString()
        mnc = CellTowerInfo.MNC.ToString()
    End Sub
    Private Sub GetCoord()
        'setup args with cellid data
        Dim args As String() = {mcc, mnc, lac, cellid}

        'call DLL to get coords and then split them.
        Dim latlng As String() = WMCellInfo.CoordinateInfo.GetLatLng(args).Split("|"c)

        'assign them to their variables.
        lat = latlng(0).ToString()
        lon = latlng(1).ToString()
    End Sub
    Private Sub GetLoc()
        'Call DLL to find location, with lat, lon parameters.
        WMCellInfo.LocationInfo.Getlocation(lat, lon)

        'Assign them into their variables.
        street = WMCellInfo.LocationInfo.locations(0)
        town = WMCellInfo.LocationInfo.locations(1)
        county = WMCellInfo.LocationInfo.locations(2)
    End Sub

   Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
        GetCellId()
      
        Label1.Text = lac & vbCrLf & mcc & vbCrLf & mnc
    End Sub

when i click on Menu_Item3, the app hangs. is there an error in my code?
 

DavidTiger

Senior Member
Nov 2, 2008
210
43
Kirkcaldy
Have you added "Imports WMCellInfo" at the very top of the code??
also
Added reference to the DLL??

other than that the code looks fine..
 

glaucos

Senior Member
Jan 18, 2007
287
3
I'm not a developer, but... I think I'll have to thank you for a future software that will use your dll :)
 

DavidTiger

Senior Member
Nov 2, 2008
210
43
Kirkcaldy
Thanks :D

Update!!
Now includes everything you need for getting your location via CellID AND GPS!!

GPS Has slightly more code to be able to use it in your project but it is necessary to use GPS :D

I have included a C# sample of using the DLL to get the location with CellID and GPS
I will also include a VB code sample in the next few days as soon as I have time to write it :)

You'll find all this in the 1st post as soon as I upload it :D

-David
 

oldsap

Senior Member
Apr 4, 2006
1,100
10
oldsap.blogspot.com
Hi david, i tried your sample code on my TD2 WM6.5 and it works. But when i use my own code:
Code:
Imports WMLocationInfo
Imports System
Imports System.IO
Imports System.Net
Imports System.Windows.Forms
Imports System.Text
Public Class Form1
    'Setup variables needed throughout the source
    Dim cellid As String, lac As String, mcc As String, mnc As String = Nothing

    Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
        Application.Exit()
    End Sub
    Public Sub GetCellID()
        'Retreive cell tower info from the DLL
        Dim CellTowerInfo As WMLocationInfo.CellIDInfo.RILCELLTOWERINFO = WMLocationInfo.CellIDInfo.GetCellTowerInfo()

        'Asign each variable with its cell data
        cellid = CellTowerInfo.CellID.ToString()
        lac = CellTowerInfo.LAC.ToString()
        mcc = CellTowerInfo.MCC.ToString()
        mnc = CellTowerInfo.MNC.ToString()

        'Show the data on the form with labels or other controls...
        Label1.Text = "CellID = " & cellid
        Label2.Text = "LAC = " & lac
        Label3.Text = "MCC = " & mcc
        Label4.Text = "MNC = " & mnc
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GetCellID()
    End Sub

End Class

it just hangs.
 

DavidTiger

Senior Member
Nov 2, 2008
210
43
Kirkcaldy
I just tested your code, copied and pasted without editing, added reference to the DLL and it works great :/

See my attached images to add reference to the DLL correctly, if you haven't already :)
I also attached the VB project I made with your code..
 

Attachments

  • 1.png
    1.png
    17.7 KB · Views: 338
  • 2.png
    2.png
    19.7 KB · Views: 314
  • 3.jpg
    3.jpg
    31.3 KB · Views: 270
  • YourCode.rar
    94.8 KB · Views: 127

DavidTiger

Senior Member
Nov 2, 2008
210
43
Kirkcaldy
Hi David, i think i found the culprit. i'm coding using DotNetv2.0 instead of 3.5
How do i integrate 3.5 to my Visual Studio 2005?

You cant im afraid. 3.5 is only available to VS2008 and above.
I'll try compiling the dll under v2.0 tomorrow as it does work I used the same code for my app in vs2005 before upgrading to 2008 with .net 3.5.
I think its because the dll is built under 3.5 their is not backward compatable but building it under v2.0 means it should work for both v2.0 and v3.5

I'll try it in the morning and post back if it works, then update the dll if it does :D

cheers,
-David
 

oldsap

Senior Member
Apr 4, 2006
1,100
10
oldsap.blogspot.com
You cant im afraid. 3.5 is only available to VS2008 and above.
I'll try compiling the dll under v2.0 tomorrow as it does work I used the same code for my app in vs2005 before upgrading to 2008 with .net 3.5.
I think its because the dll is built under 3.5 their is not backward compatable but building it under v2.0 means it should work for both v2.0 and v3.5

I'll try it in the morning and post back if it works, then update the dll if it does :D

cheers,
-David

wow. thank you for your effort and time David.
 

DavidTiger

Senior Member
Nov 2, 2008
210
43
Kirkcaldy
This is only a DLL(Dynamc Link Library) of code which you can use to build your own program, using .netv2.0 and above with Visual Studio 2005-2008..

You can test the app I posted in post #1... Just copy the exe and dll from the bin/release folder and run it on your device..

Other than that you will have to write your own program to make use of this :)
An example is my 'Facebook Location' app I've posted :D
 

DavidTiger

Senior Member
Nov 2, 2008
210
43
Kirkcaldy
Yea, now I've downgraded the DLL I'll rewrite the VB and C# sample projects with 2005 anyone who uses 2008 it will update the project itself.
Gives the most compatibility, and use for people :D
 

deedee

Senior Member
May 28, 2007
1,048
26
Coleraine
Yea, now I've downgraded the DLL I'll rewrite the VB and C# sample projects with 2005 anyone who uses 2008 it will update the project itself.
Gives the most compatibility, and use for people :D

Thanks, I could probably work through a VS2005 C# project but a VB one would be just ideal.

Just donated, have a beer or two on me. Would say whisky but the Irish stuff is better. LOL We have the best distillery 10 miles down the road.
 
Last edited:

DavidTiger

Senior Member
Nov 2, 2008
210
43
Kirkcaldy
Thanks! Can't say I've had many Irish whiskeys :D Jameson is about the only one I've tried. Oh and I had a glass or two of one my dad had, uhm Paddy I think it was called... 80 proof one ;)
Mostly Scotch lol

I'll post up the VB one first, should be <30 minutes :)
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    [01/2/11] Update v2.1 - Downgraded .net to v2.0 - Should now work with VS2005!
    [31/1/11] Update v2 - Now includes GPS Support!
    [30/1/11] Update v1 - Initial Release - CellID Only!

    I have created this DLL to allow developers to quickly and easily add support for locations. By using CellID and now GPS!

    CellID: This way is done by getting looking at the Cell Towers your mobile is connected to.. and then by searching a database of Cell Locations you can work out an approximate location for your Device, Which is usually accurate within 50-100m!

    GPS: I'm sure we all know what GPS is and how it works :) Instead of using the Cell Tower location to find your location, It takes the co-ordinates from the GPS to then query an online source to figure out your location, Which is as accurate as GPS can get! If you're outside and not blocked by many buildings it should be as accurate as <5m :D

    To download see the attachments 'WMLocationInfo.rar' contains the DLL file only..
    If you are unsure how to go about using this DLL, I have included a sample C# application with full source code, This will show you how to get location by both CellID and GPS :)

    Please take note of the copyright info below, before downloading and using my DLL and/or Source Codes :cool:

    Thanks,
    -David!

    Copyright © 2011 David Bell / DavidTiger All Rights Reserved.
    All Source Code, Compiled exe and DLL files are the copyrighted works of David Bell/DavidTiger.
    You may use/redistribute any included samples or files, but you MUST leave credits where due.
    You may NOT include this DLL and/or use its function in any commercial products with an intend to make a profit without written permission first!
    All compiled DLL/EXE which do not include a source code have been obfuscated
    You also may NOT attempt to dissasemble or reverse engineer any compiled obfuscated distributables (exe/dll).
    1
    Okay, took longer than expected as I had to change the GPS procedure to use a timer, then disable it when location was found..

    Tested and it works for both CellID and GPS :D

    You'll find in an post #1
    1
    I'll have a look but I don't think it may be possible as, unlike GPS the CellID doesn't call a handler when the Cell Tower changes :/

    I'll certainly have a try at adding some sort of code that can automatically update it if the Tower changes..