Notifying and Deregistering Procedures

The notification process follows the same basic steps for connection and disconnection of the Windows CE–based device. The following procedure assumes that the IDccMan and IDccManSink interfaces have been implemented.

    To register an application by using COM interface–based notification

  1. Initialize the COM library and register the application for the appropriate event.
  2. Connect or disconnect the device.
  3. Perform the application processing.

The Connection Notification Client sample application, provided on the CD-ROM that accompanies this documentation, shows several connection notification scenarios, including a new remote connect, a disconnect, and a reconnect. To see the actual sequence of interface method calls for any of these scenarios, build and run the application. Then, in the Connection Notification Test dialog box, view the Notification Messages list.

    To receive notification upon connection of the Windows CE–based device to a desktop computer

  1. Initialize the COM library and register with the connection manager.
  2. Establish the connection between the desktop computer and the device.

    Note When the IDccManSink::OnLogIpAddr notification occurs, the connection is completely established.

  3. Perform your processing in the application.

    This can include processing on the desktop computer, remote processing on the device by using remote application programming interface (RAPI), or calling the IDccMan methods. However, the application should wait to use CeRapiInit to initialize RAPI until the IDccManSink::OnLogActive notification is received. This ensures that a connection is established between the desktop computer and the device.

    To receive notification upon disconnection of the Windows CE–based device from the desktop computer

  1. Initialize the COM library and register the application.
  2. Disconnect the device from the desktop computer.

    Windows CE Services notifies the application when the desktop computer and device are disconnected by calling the IDccManSink::OnLogDisconnection method.

  3. Perform your processing in the application.

    Because there is no connection to the device, this processing can only take place on the desktop computer.

    To receive notification when reestablishing a remote connection

The Connection Notification Client source code uses the IDccMan interface and implements the IDccManSink interface.

    To deregister an application from being notified

One of the advantages to using the COM interface–based notification process is that it allows an application to deregister itself from being notified. This might be helpful when an application needs to run only once.

  1. Call IDccMan::Unadvise, which releases the memory associated with the IDccManSink interface.
  2. Call IDccMan::Release, which releases the IDccMan object.
  3. Call CoUninitialize to perform any OLE cleanup.

    Note that a call to CoUninitialize is required for each successful call to CoInitialize.