Click here to Skip to main content
15,886,873 members
Articles / Mobile Apps / Windows Mobile

Handling connection notification between a desktop machine and Windows CE based devices

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
14 Jan 2009CPOL4 min read 80.8K   665   53  
This article describes how to get notification when a Windows CE based device is connected or disconnected from a desktop machine.
Imports System.Runtime.InteropServices
''' <summary>
''' This event handler is used to register the event on Connection.
''' </summary>
<Serializable()> <ComVisible(True)> Public Delegate Sub ActiveHandler()
''' <summary>
''' This event handler is used to register the event on DisConnection.
''' </summary>
<Serializable()> <ComVisible(True)> Public Delegate Sub DisconnectHandler()
''' <summary>
''' This class is used to get the instance of IDccManSink. It is implemented by
''' Connection Manager of ActiveSynk.
''' </summary>
<ComImport(), Guid("499C0C20-A766-11cf-8011-00A0C90A8F78")> _
Public Class DccMan
End Class
''' <summary>
''' This Interface is used to get all the methods available in the IDccMan. with the help of 
''' this interface we can register / deregister the IDccManSink.
''' </summary>
<ComImport(), Guid("A7B88841-A812-11cf-8011-00A0C90A8F78"), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
Public Interface IDccMan
    Function Advise(ByVal pDccSink As IDccManSink, _
                    ByRef dwContext As Int32) As Int32
    Function Unadvise(ByVal dwContext As Int32) As Int32
    Sub ShowCommSettings()
    Sub AutoconnectEnable()
    Sub AutoconnectDisable()
    Sub ConnectNow()
    Sub DisconnectNow()
    Sub SetIconDataTransferring()
    Sub SetIconNoDataTransferring()
    Sub SetIconError()
End Interface
''' <summary>
''' This Interface is used to get all the methods available in the IDccManSink.
''' </summary>
<Guid("A7B88840-A812-11cf-8011-00A0C90A8F78"), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
Public Interface IDccManSink
    <PreserveSig()> Function OnLogIpAddr(<InAttribute()> ByVal dwIpAddr As Int32) As Int32
    <PreserveSig()> Function OnLogTerminated() As Int32
    <PreserveSig()> Function OnLogActive() As Int32
    <PreserveSig()> Function OnLogInactive() As Int32
    <PreserveSig()> Function OnLogAnswered() As Int32
    <PreserveSig()> Function OnLogListen() As Int32
    <PreserveSig()> Function OnLogDisconnection() As Int32
    <PreserveSig()> Function OnLogError() As Int32
End Interface
''' <summary>
''' This class is used to define all the methods of IDccManSink. the methods of this class gets
''' triggered on connection / disconnection.
''' </summary>
''' <remarks></remarks>
<Guid("C6659361-1625-4746-931C-36014B146679")> _
Public Class DccManSink
    Implements IDccManSink
    Public Event Active As ActiveHandler
    Public Event Disconnect As DisconnectHandler
    Public Function OnLogActive() As Int32 Implements IDccManSink.OnLogActive
        RaiseEvent Active()
    End Function

    Public Function OnLogAnswered() As Int32 Implements IDccManSink.OnLogAnswered

    End Function

    Public Function OnLogDisconnection() As Int32 Implements IDccManSink.OnLogDisconnection
        RaiseEvent Disconnect()
    End Function

    Public Function OnLogError() As Int32 Implements IDccManSink.OnLogError
    End Function

    Public Function OnLogInactive() As Int32 Implements IDccManSink.OnLogInactive
    End Function

    Public Function OnLogIpAddr(ByVal dwIpAddr As Int32) As Int32 Implements IDccManSink.OnLogIpAddr
    End Function

    Public Function OnLogListen() As Int32 Implements IDccManSink.OnLogListen
    End Function

    Public Function OnLogTerminated() As Int32 Implements IDccManSink.OnLogTerminated
    End Function
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer Microsoft India
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions