The ActiveSync Manager

The ActiveSync Manager (or just ActiveSync) is an application that runs on both your desktop and Pocket PC device, and is responsible for maintaining the partnerships between them (see Figure 9.1). It also handles the connection (over USB, Network, and so on), synchronization, and the replication of data between a device and its desktop counterpart.

Figure 9.1. The desktop ActiveSync Manager

graphics/09fig01.gif

There are two main components to ActiveSync: the Service Manager and Service Providers.

The Service Manager is responsible for comparing data on the Pocket PC device with that on the desktop. Once it has looked at the data on both for a particular application (and based on synchronization rules the user has configured), it will update them with the most recent information. Think of it as the synchronization engine for your data (see Figure 9.2). The ActiveSync Manager is the application that an end user works with to configure service providers and their configuration options. In addition, ActiveSync is also responsible for connectivity services, either locally or remotely, that can be established over a serial, infrared, Ethernet, or wireless connection.

Figure 9.2. ActiveSync synchronization options

graphics/09fig02.gif

The other half of ActiveSync is the Service Providers. A service provider is a COM component that is registered within the Service Manager and provides specific synchronization functionality for a particular application. For example, applications such as Pocket Outlook, Inbox, Pocket Word, and Pocket Excel all have ActiveSync Service Providers. A typical service provider will consist of two modules: one that runs on the desktop and one that runs on a Pocket PC device.

Another type of service provider that ActiveSync will also use is File Filters. File Filters run on the desktop and are used to handle the conversion of a particular file type when copied between a device and a desktop computer. File Filters are also registered with the Service Manager.

Using the ActiveSync Manager

The ActiveSync Manager is typically launched when a connection is established to a Pocket PC device. If you need to manually execute it, the safest way to find out where it is located is by looking in the desktop's registry. You will need to examine the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services and look at the InstalledDir subkey value. This will contain the path that ActiveSync was installed in. You can then run the wcesmgr.exe executable to start the Service Manager.

When starting ActiveSync, you can run it with any of the command-line options described in Table 9.1.

Table 9.1. ActiveSync Manager Command-Line Options

Parameter

Description

 

No command-line parameter. This will just run ActiveSync without displaying the status window.

/quit

Shuts down ActiveSync while keeping a connection active.

/show

Starts ActiveSync and makes the status window visible.

/syncmgr

Starts ActiveSync and displays the Options dialog box.

/syncnow

Starts ActiveSync and immediately synchronizes data with the connected device.

Let's take a look at how you can use the CreateProcess() function to start ActiveSync on your desktop:

 // Open the registry HKEY hKey = NULL; TCHAR tchPath[MAX_PATH+1] = TEXT("\0"); TCHAR tchActiveSyncInsPath[MAX_PATH+1] = TEXT("\0"); DWORD dwSize = MAX_PATH; wsprintf(tchPath, TEXT("SOFTWARE\\Microsoft\\Windows CE   Services")); if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, tchPath, 0, KEY_READ,    &hKey) != ERROR_SUCCESS)    return FALSE; // Get the path to where ActiveSync is installed if(RegQueryValueEx(hKey, TEXT("InstalledDir"), NULL, NULL,     (LPBYTE)&tchActiveSyncInsPath, &dwSize) !=     ERROR_SUCCESS) {    RegCloseKey(hKey);    return FALSE; } if(hKey)    RegCloseKey(hKey); // Launch it STARTUPINFO si; PROCESS_INFORMATION pi; _tcsncat(tchActiveSyncInsPath, TEXT("\\wcesmgr.exe"),   MAX_PATH); memset(&si, 0, sizeof(STARTUPINFO)); memset(&pi, 0, sizeof(PROCESS_INFORMATION)); si.cb = sizeof(STARTUPINFO); CreateProcess(tchActiveSyncInsPath, NULL, NULL, NULL, FALSE,    NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); 

Note that ActiveSync uses a proprietary protocol known as Direct Cable Connect Manager (DCCM) to send commands, replicate information, and communicate with a connected device. In order for ActiveSync to work properly, you need to ensure that the TCP/IP ports 990, 999, 5678, and 5679 are available for it to use.

More information about configuring a system to use DCCM can be found in the Microsoft Knowledge Base article Q259369, located at http://support.microsoft.com/default.aspx?scid=kb;en-us;259369.



Pocket PC Network Programming
Pocket PC Network Programming
ISBN: 0321133528
EAN: 2147483647
Year: 2005
Pages: 90

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net