About the Connection Manager Helper Sample

The Connection Manager Helper sample, located at C:\Program Files\Windows CE Tools\wce420\POCKET PC 2003\Samples\Mfc\Cmhelper, obtains the proxy information provided the user and automates the proxy definition and questioning process. This eliminates the need to include proxy information in the application code.

Note   The Connection Manager Helper sample does not perform the following functions. You can use the Connection Manager API to implement this additional functionality.

  • Scheduling background tasks
  • Altering connection priority (changing the priority of an application while it is running is strongly discouraged)

When running the sample, to prevent the device from automatically entering a suspended state when you're transferring data, call the Windows CE SystemIdleTimerReset function. This function overrides the registry setting that determines the length of time the device waits before entering into a suspended state and shuts down the device, ending the transfer of information. The SystemIdleTimerReset function is documented in the Windows CE reference section of MSDN Library.

Note   On battery-powered devices, a program that continually calls SystemIdleTimerReset can quickly drain the batteries. For more information, see How to: Prevent Automatic Power Down.

The following table describes the functions used in the Connection Manager Helper sample.

Function Description
IsAvailable Checks for an Internet or corporate network connection by determining whether the connection could be made in less than four seconds. The function does not identify how the connection was made (an Internet connection through an ISP or an intranet connection through a corporate network).

If four seconds elapse, no connection is detected. The ulMaxConnLatency parameter determines the length of time. The value is set to 4,000 milliseconds.

If the function detects a connection, an application can use that connection without requiring any additional user action.

The function is synchronous. While it is running, the Windows Mobile-based device is waiting for a result and the user is unable to use the UI.

AttemptConnect Establishes a new connection to a given network based on the network path name, utilizing connection settings configured by the user. If a connection already exists, the function opens a different connection, causing the current connection to be dropped.

If the network path name points to the Internet, the function uses the ISP connection. If the path name points to an intranet site, the function uses the corporate network connection.

The function is asynchronous. When it sends its callback function to the application, the callback function runs on a different thread. This requires the application to update the UI separately based on the status of the connection attempt.

DoStatusUpdate Interprets the value of a bit field that contains the status of a connection attempt and then calls the appropriate function.

Connection Manager provides the bit field. For information about the bit field values, see the Connection Manager API.

DoConnectingError Displays an error message when an error occurs during the connection. Typically, an error occurs because a network card or modem is not installed on the device.

You can customize the error message.

DoConnected Returns a callback function indicating that a network connection is available, after a connection has been established and socket calls are possible.

Your application should derive from this function and then overwrite it with the specific connection information for the Windows Mobile-based device.

DoDisconnected Indicates that the current connection has been dropped by another network request
DoReleaseConnection Releases an open connection and caches it for a few minutes. Caching enables the connection to be immediately reopened.

You should call this function after all necessary data is obtained.

If you call the function for an object that has already been released, you receive a shutdown error .

It is recommended that you use this function to inform Connection Manager that an application has finished using the connection. This enables other applications that are sharing the connection to continue until all of the applications have called this function.

HangupConnection Releases an open connection without caching the connection.

See Also

Connection Manager

Connection Manager API

How to: Prevent Automatic Power Down

Send feedback on this topic to the authors.

© 2005 Microsoft Corporation. All rights reserved.