Detect ActiveSync/Cradle Connection

Hi all,

I need to sync data with a web service runing in my network when connect my device to PC. How can i detect if ActiveSync is runing in my device

I'm using .NET CF 2.0 with a PocketPC 2003 device.

I try to use OpenNetCF 2.0, but this release not includes "Desktop.ActiveSync" namespace.

Thanks. Jose Miguel.



Answer this question

Detect ActiveSync/Cradle Connection

  • dreameR.78

    Warren LaFrance wrote:

    In my forms I call this class on the form when a NEW Instance is created..

    I found this info at :http://www.devbuzz.com/content/zinc_network_connectivity_pg1.asp

    In the form class...

    ----------

    Public Sub New()

    ' This call is required by the Windows Form Designer.

    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.

    Dim connectionStatus As connectStatus = New connectStatus

    Dim myStatus As String = connectionStatus.IsDeviceCradled.ToString

    MsgBox(myStatus)

    If Not connectionStatus.IsDeviceCradled = CradleResult.Cradled Then

    MsgBox("You must Cradle your device before accessing this functionality", MsgBoxStyle.Critical, "Device Connection Status")

    Me.Dispose()

    End If

    End Sub

    ------------------------

    Create new class...

    Imports System.Net

    'Helper class to determine if the device is connected...

    #Region "ENUMS"

    Public Enum CradleResult As Integer

    Cradled = 0

    Uncradled = 1

    WebException = 2

    OtherException = 3

    End Enum

    #End Region

    Public Class connectStatus

    #Region "CONSTANT"

    Const Home As String = "127.0.0.1" 'The ip address of a uncraddled machine

    #End Region

    Public Function IsDeviceCradled() As CradleResult

    Try

    Dim HostName As String = Dns.GetHostName()

    'Dim IPHost As System.Net.IPHostEntry = Dns.GetHostByName(HostName)

    Dim IPHost As System.Net.IPHostEntry = Dns.GetHostEntry(HostName)

    Dim DeviceIP As String = IPHost.AddressList(0).ToString

    If DeviceIP <> IPAddress.Parse(Home).ToString Then

    Return CradleResult.Cradled

    Else

    Return CradleResult.Uncradled

    End If

    Catch webEx As System.Net.WebException

    Return CradleResult.WebException

    Catch otherEx As System.Exception

    Return CradleResult.OtherException

    End Try

    End Function

    End Class

    the above method requires internet connections


  • rad2319

    Thanks Alex, This is just that i need!
  • HuWu

    In my forms I call this class on the form when a NEW Instance is created..

    I found this info at :http://www.devbuzz.com/content/zinc_network_connectivity_pg1.asp

    In the form class...

    ----------

    Public Sub New()

    ' This call is required by the Windows Form Designer.

    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.

    Dim connectionStatus As connectStatus = New connectStatus

    Dim myStatus As String = connectionStatus.IsDeviceCradled.ToString

    MsgBox(myStatus)

    If Not connectionStatus.IsDeviceCradled = CradleResult.Cradled Then

    MsgBox("You must Cradle your device before accessing this functionality", MsgBoxStyle.Critical, "Device Connection Status")

    Me.Dispose()

    End If

    End Sub

    ------------------------

    Create new class...

    Imports System.Net

    'Helper class to determine if the device is connected...

    #Region "ENUMS"

    Public Enum CradleResult As Integer

    Cradled = 0

    Uncradled = 1

    WebException = 2

    OtherException = 3

    End Enum

    #End Region

    Public Class connectStatus

    #Region "CONSTANT"

    Const Home As String = "127.0.0.1" 'The ip address of a uncraddled machine

    #End Region

    Public Function IsDeviceCradled() As CradleResult

    Try

    Dim HostName As String = Dns.GetHostName()

    'Dim IPHost As System.Net.IPHostEntry = Dns.GetHostByName(HostName)

    Dim IPHost As System.Net.IPHostEntry = Dns.GetHostEntry(HostName)

    Dim DeviceIP As String = IPHost.AddressList(0).ToString

    If DeviceIP <> IPAddress.Parse(Home).ToString Then

    Return CradleResult.Cradled

    Else

    Return CradleResult.Uncradled

    End If

    Catch webEx As System.Net.WebException

    Return CradleResult.WebException

    Catch otherEx As System.Exception

    Return CradleResult.OtherException

    End Try

    End Function

    End Class


  • Kamii47

    Take a look at the OpenNETCF.WindowsCE.DeviceManagement class in the SDF v2.
  • Detect ActiveSync/Cradle Connection