Microsoft KB Archive/317171

= INFO: Configuring Auto-Connect Notification for ActiveSync =

Article ID: 317171

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Windows CE 3.0 for the Handheld PC
 * Microsoft Encarta Reference Suite 2001
 * Microsoft Windows CE Platform Builder 4.0
 * Microsoft Windows CE .NET 4.2

-



This article was previously published under Q317171



SUMMARY
A common implementation of Microsoft ActiveSync services on a device involves configuring a designated hardware port to automatically start ActiveSync when the port detects that the device has been connected to another device (or &quot;cradled&quot;). This article describes how the notification system is used to start ActiveSync components on a Windows CE-based device, and how to use the notification system in Platform Builder.



MORE INFORMATION
Currently, the mechanism that is used by Windows CE to start ActiveSync when a designated hardware port event occurs is to use the notification system. The notification system provides the NOTIFICATION_EVENT_RS232_DETECTED event as a link between the hardware event and starting ActiveSync. A device driver is responsible for detecting the appropriate hardware event and starting an event by using the CeEventHasOccurred function. This event causes the system to read a corresponding notification database record and to start the associated program. By default, this program is ActiveSync.

Typical platform implementations use a serial port for ActiveSync automatic connections. The notification is started when the carrier-detect signal is asserted (this is the bases for the notification event name). The hardware event can also take other forms such as detecting a connection on a USB port.

This event is designed to report a hardware connection on a physical port. The event does not indicate which program or server might be running at the other end of the connection. For example, with a serial port, ActiveSync is started if the device is connected to an RS-232 dumb terminal that asserts carrier detect by using a null modem cable.

Triggering the Event
To start the event, call the following function (which is defined in the Platform Builder headers):

BOOL CeEventHasOccurred (LONG lWhichEvent, TCHAR *pwszEndOfCommandLine);

For auto-connect events, the first parameter is used to pass NOTIFICATION_EVENT_RS232_DETECTED. You can use the second parameter to pass additional parameters to the program that is started. Most implementations pass NULL. For example, you can use this parameter to pass the port name on which the event originates.

Configuring the Program That Is Started
The program that is started for a particular event is stored in the object store property database. The value is defined in Wceappsfe.db:

Record :

Field : 0001001f : &quot;repllog.exe&quot;

Field : 0002001f : &quot;AppRunAtRs232Detect&quot;

Field : 00030013 : 9

End

The first field contains the name of the program file to start. The second field contains the initial parameter that is passed to the program, which is used to identify the event that started the program. The third field identifies the record with NOTIFICATION_EVENT_RS232_DETECTED.

You can change this record at run time by using the CeRunAppAtEvent function.

Starting the Program
After the event is triggered, the notification system starts the configured program. The command line at the program entry point has one or more parameters. The first parameter is the event name that is specified in the database record (for example, &quot;AppRunAtRs232Detect&quot;). The remainder of the command line is supplied by the pwszEndOfCommandLine parameter when the driver calls CeEventHasOccurred.

Keywords: kbenv kbinfo KB317171

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.