gpsdevicestate.vb
来自「清华大学出版社出版的 移动应用开发宝典 张大威(2008)的附书源代码」· VB 代码 · 共 81 行
VB
81 行
Imports System.Runtime.InteropServices
Namespace Microsoft.WindowsMobile.Samples.Location
Public Enum GpsServiceState
Unknown = -1
[Off] = 0
[On] = 1
StartingUp = 2
ShuttingDown = 3
Unloading = 4
Uninitialized = 5
End Enum
Public Class GpsDeviceState
Private m_device As GPS_DEVICE
Public Const GpsDeviceStructureSize As Integer = &HD8
Friend Sub New(ByVal device As GPS_DEVICE)
m_device = device
End Sub
Public ReadOnly Property DeviceState() As GpsServiceState
Get
Return DirectCast(m_device.dwDeviceState, GpsServiceState)
End Get
End Property
Public ReadOnly Property DriverPrefix() As String
Get
Return m_device.szGPSDriverPrefix
End Get
End Property
Public ReadOnly Property FriendlyName() As String
Get
Return m_device.szGPSFriendlyName
End Get
End Property
Public ReadOnly Property MultiplexPrefix() As String
Get
Return m_device.szGPSMultiplexPrefix
End Get
End Property
Public ReadOnly Property ServiceState() As GpsServiceState
Get
Return DirectCast(m_device.dwServiceState, GpsServiceState)
End Get
End Property
End Class
<StructLayout(LayoutKind.Sequential)> _
Friend Structure GPS_DEVICE
Friend Const GPS_MAX_FRIENDLY_NAME As Integer = &H40
Friend Const GPS_MAX_PREFIX_NAME As Integer = &H10
Public dwVersion As Integer
Public dwSize As Integer
Public dwServiceState As Integer
Public dwDeviceState As Integer
Public ftLastDataReceived As Long
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=&H10)> _
Public szGPSDriverPrefix As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=&H10)> _
Public szGPSMultiplexPrefix As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=&H40)> _
Public szGPSFriendlyName As String
End Structure
End Namespace
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?