使用c#获取笔记本电脑的位置 [英] Get my laptop location using c#
本文介绍了使用c#获取笔记本电脑的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我们可以使用win-form应用程序获取我们的客户位置(纬度,经度)吗?
提前谢谢。
Hello,
Can we get our client location (latitude,longitude) using a win-form application ?
Thanks in advance.
推荐答案
我从未使用过这个,但这看起来就像你需要的那样。文档说如果没有GPS可用,它将使用Wi-Fi三角测量。我不知道它是否会对有线连接做同样的事情。没有GPS,它将不如GPS准确。没有GPS,它可能使用您的ISP的位置。尝试一下,让我们知道它是如何工作的。
参见 System.Device.Location命名空间 [ ^ ]和 GeoCoordinateWatcher类 [ ^ ]。
我在Windows 8 Wi-Fi和有线连接上使用它。有线连接测试可能使用记忆的Wi-Fi测试坐标。
添加对参考:System.Device
I have never used this but this looks like what you need. The documentation says if no GPS is available it will use Wi-Fi triangulation. I don't know if it would do the same for a wired connection. Without a GPS, it will not be as accurate as a GPS. Without a GPS, it is probably using the location of your ISP. Try it and let us know how it works.
See System.Device.Location Namespace[^] and GeoCoordinateWatcher Class[^].
I got this to work on Windows 8 Wi-Fi and wired connection. It is possible that the wired connection test used remembered coordinates from the Wi-Fi test.
Add a Reference to: System.Device
Imports System.Device.Location
Private WithEvents watcher As GeoCoordinateWatcher
Public Sub GetLocationDataEvent()
watcher = New System.Device.Location.GeoCoordinateWatcher()
AddHandler watcher.PositionChanged, AddressOf watcher_PositionChanged
watcher.Start()
End Sub
Private Sub watcher_PositionChanged(ByVal sender As Object, ByVal e As GeoPositionChangedEventArgs(Of GeoCoordinate))
MsgBox(e.Position.Location.Latitude.ToString & ", " & _
e.Position.Location.Longitude.ToString)
' Stop receiving updates after the first one.
watcher.Stop()
End Sub
这篇关于使用c#获取笔记本电脑的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文