⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 367-372.html

📁 WindowsCE.[Essential Windows CE Application Programming].Jon Wiley & Son.zip
💻 HTML
📖 第 1 页 / 共 2 页
字号:
	</tr>
	</table>
	</form>
<!-- LEFT NAV SEARCH END -->

		</td>
		
<!-- PUB PARTNERS END -->
<!-- END LEFT NAV -->

<td rowspan="8" align="right" valign="top"><img src="/images/iswbls.gif" width=1 height=400 alt="" border="0"></td>
<td><img src="/images/white.gif" width="5" height="1" alt="" border="0"></td>
<!-- end of ITK left NAV -->

<!-- begin main content -->
<td width="100%" valign="top" align="left">


<!-- END SUB HEADER -->

<!--Begin Content Column -->

<FONT FACE="Arial,Helvetica" SIZE="-1">
To access the contents, click the chapter and section titles.
</FONT>
<P>
<B>Essential Windows CE Application Programming</B>
<FONT SIZE="-1">
<BR>
<I>(Publisher: John Wiley & Sons, Inc.)</I>
<BR>
Author(s): Robert Burdick
<BR>
ISBN: 0471327476
<BR>
Publication Date: 03/01/99
</FONT>
<P>
<form name="Search" method="GET" action="http://search.earthweb.com/search97/search_redir.cgi">

<INPUT TYPE="hidden" NAME="Action" VALUE="Search">
<INPUT TYPE="hidden" NAME="SearchPage" VALUE="http://search.earthweb.com/search97/samples/forms/srchdemo.htm">
<INPUT TYPE="hidden" NAME="Collection" VALUE="ITK">
<INPUT TYPE="hidden" NAME="ResultTemplate" VALUE="itk-simple-intrabook.hts">
<INPUT TYPE="hidden" NAME="ViewTemplate" VALUE="view.hts">

<font face="arial, helvetica" size=2><b>Search this book:</b></font><br>
<INPUT NAME="queryText" size=50 VALUE="">&nbsp;<input type="submit" name="submitbutton" value="Go!">
<INPUT type=hidden NAME="section_on" VALUE="on">
<INPUT type=hidden NAME="section" VALUE="http://www.itknowledge.com/reference/standard/0471327476/">

</form>


<!-- Empty Reference Subhead -->

<!--ISBN=0471327476//-->
<!--TITLE=Essential Windows CE Application Programming//-->
<!--AUTHOR=Robert Burdick//-->
<!--PUBLISHER=John Wiley & Sons, Inc.//-->
<!--IMPRINT=Wiley Computer Publishing//-->
<!--CHAPTER=14//-->
<!--PAGES=367-372//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="366-367.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="372-375.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading4"></A><FONT COLOR="#000077">The Synchronization Process from the 50,000-Foot Level</FONT></H3>
<P>Writing ActiveSync service providers requires understanding a number of subtle programming steps. Understanding these steps will be much easier if we first examine the whole data synchronization process from a higher, more abstract level.
</P>
<P>When a Windows CE device connects to a desktop PC, the following steps take place to synchronize a particular application data type:</P>
<DL>
<DD><B>1.</B>&nbsp;&nbsp;The ActiveSync service manager determines what service providers are installed on the PC and the device by looking in the desktop and device registries.
<DD><B>2.</B>&nbsp;&nbsp;With the help of the desktop service provider, the service manager reconstructs the data folder (HREPLFLD) and all of the items (HREPLITEM) it contained during the <I>previous</I> synchronization.
<DD><B>3.</B>&nbsp;&nbsp;The desktop service provider enumerates all of the objects currently contained by the application data store, passing an HREPLITEM back to the manager for each enumerated data store object.
<DD><B>4.</B>&nbsp;&nbsp;The service manager creates new entries in REPL.DAT for any new data objects returned by the service provider&#146;s object enumeration. For old objects, the service manager asks the service provider if the object has changed since the last synchronization. If an object has changed, the service manager gets the new object from the service provider.
<DD><B>5.</B>&nbsp;&nbsp;New objects are transferred to the Windows CE device by the service manager. This is done with the help of the desktop service provider, which converts each object to be transferred into a binary data packet.
</DL>
<P>A similar set of operations take place over on the device side:
</P>
<DL>
<DD><B>1.</B>&nbsp;&nbsp;The device ActiveSync service manager enumerates all device data store objects.
<DD><B>2.</B>&nbsp;&nbsp;For each enumerated object, the device service provider tells the service manager whether or not the object needs to be synchronized.
<DD><B>3.</B>&nbsp;&nbsp;For each object requiring synchronization, the service provider converts the object data into a binary packet.
<DD><B>4.</B>&nbsp;&nbsp;The packets are transferred by the service manager.
</DL>
<P>The steps above are executed by the service manager and service provider software to perform data synchronization. Data synchronization can also be looked at from the point of view of the data being synchronized:
</P>
<DL>
<DD><B>1.</B>&nbsp;&nbsp;The data that was synchronized during the last data synchronization operation is reconstructed. This is done to facilitate the comparison of current data store objects with those in REPL.DAT to decide what data needs to be synchronized.
<DD><B>2.</B>&nbsp;&nbsp;Data store objects are converted into packets for transfer by the ActiveSync service manager.
<DD><B>3.</B>&nbsp;&nbsp;Transferred data is converted from binary packets back into the data object format used internally by the application.
</DL>
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">Registering ActiveSync Service Providers</FONT></H3>
<P>In the previous section I said that service providers get registered in the desktop or device registry. This is required so that the ActiveSync service manager can determine what service providers to initialize in order to synchronize their corresponding application data. Let&#146;s look at how to register the service providers for the phone list application.
</P>
<P>It might seem that this should be described after we have developed the service provider DLLs. However, understanding how service providers are registered will help you understand how the service manager initializes service providers. It will also make it easier to understand how the data synchronization process is started.</P>
<P>So, let&#146;s assume that we have implemented a device service provider in the dynamic link library PHDEVS.DLL. We also have the desktop provider, PHSYNC.DLL. These service providers are used by ActiveSync to synchronize phone database entries used by the phone list application.</P>
<P><FONT SIZE="+1"><B>Registering the Desktop Service Provider</B></FONT></P>
<P>Recall that the device service provider DLL is an in-process COM server implementing the COM interfaces IReplStore and IReplObjHandler. The service manager implements the IReplNotify COM interface. The service manager uses COM to create instances of the interfaces implemented by the service provider.
</P>
<P>The service manager creates instances of the service providers it uses by finding the <I>class identifiers</I> for each of the service providers. This class identifier is a globally unique identifier value, or GUID. Using this identifier, the service manager can search the registry for the path of the DLL that implements the service provider interfaces.</P>
<P>To facilitate this process, a service provider must first be registered under the HKEY_CLASSES_ROOT registry key. The registry subkeys required are given in Figure 14.1.</P>
<P><A NAME="Fig1"></A><A HREF="javascript:displayWindow('images/14-01.jpg',640,61 )"><IMG SRC="images/14-01t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/14-01.jpg',640,61)"><FONT COLOR="#000077"><B>Figure 14.1</B></FONT></A>&nbsp;&nbsp;Registry subkeys for registering a desktop ActiveSync service provider.</P>
<P>&lt;Class ID&gt; represents the service provider&#146;s class identifier. This identifier is a globally unique identifier, or GUID. It can be generated by running the GUIDGEN.EXE program that ships with Microsoft Developer Studio. This program user interface is shown in Figure 14.2.
</P>
<P><A NAME="Fig2"></A><A HREF="javascript:displayWindow('images/14-02.jpg',375,339 )"><IMG SRC="images/14-02t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/14-02.jpg',375,339)"><FONT COLOR="#000077"><B>Figure 14.2</B></FONT></A>&nbsp;&nbsp;Running GUIDGEN.EXE.</P>
<P>Selecting the registry format option as shown and pressing the New GUID button will create a new GUID in the format expected by the Windows registry. Next, press the Copy button. This copies the newly created GUID to the clipboard.
</P>
<P>ProgID contains a <I>programmatic identifier</I> that uniquely identifies the service provider. This identifier typically consists of a company name followed by an application name. In our example, the service identifier is given the programmatic identifier <B>Wiley.PhoneApp</B>.</P>
<P>Finally, the InProcServer32 subkey contains the full path name of the DLL that implements the service provider.</P>
<P>Now create a file named PHONEDESK.REG and add the text shown in Figure 14.3. You should replace the GUID 025A8621-56FE-11d2-9BCC-000000000000 with the GUID you just created with GUIDGEN.EXE. If you copied your new GUID to the clipboard as described previously, you can simply paste your GUID over every occurrence of the GUID 025A8621-56FE-11d2-9BCC-000000000000.</P>
<P><A NAME="Fig3"></A><A HREF="javascript:displayWindow('images/14-03.jpg',640,236 )"><IMG SRC="images/14-03t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/14-03.jpg',640,236)"><FONT COLOR="#000077"><B>Figure 14.3</B></FONT></A>&nbsp;&nbsp;The PHONEDESK.REG registry file.</P>
<P>What you now have is a registry file that will automatically create all of the registry subkeys shown in Figure 14.1. The path defined in the InProcServer32 subkey should be changed so that it contains the correct location of PHSYNC.DLL on your desktop computer.
</P>
<P>Service providers for other applications will have different programmatic identifiers and, of course, different class identifiers.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="366-367.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="372-375.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>


<!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->

<!-- BEGIN SUB FOOTER -->
		<br><br>
		</TD>
    </TR>
	</TABLE>

		
	<table width="640" border=0 cellpadding=0 cellspacing=0>
		<tr>
		<td align="left" width=135><img src="/images/white.gif" width=100 height="1" alt="" border="0"></td>
		
		
<!-- END SUB FOOTER -->

<!-- all of the books have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->

<!-- FOOTER -->
			
		<td width="515" align="left" bgcolor="#FFFFFF">
<font face="arial, helvetica" size="1"><b><a href="/products.html"><font color="#006666">Products</font></a>&nbsp;|&nbsp; <a href="/contactus.html"><font color="#006666">Contact Us</font></a>&nbsp;|&nbsp; <a href="/aboutus.html"><font color="#006666">About Us</font></a>&nbsp;|&nbsp; <a href="http://www.earthweb.com/corporate/privacy.html" target="_blank"><font color="#006666">Privacy</font></a> &nbsp;|&nbsp; <a href="http://www.itmarketer.com/" target="_blank"><font color="#006666">Ad Info</font></a> &nbsp;|&nbsp; <a href="/"><font color="#006666">Home</font></a></b>
		<br><br>
		
		Use of this site is subject to certain <a href="/agreement.html">Terms &amp; Conditions</a>, <a href="/copyright.html">Copyright &copy; 1996-1999 EarthWeb Inc.</a><br> 
All rights reserved.  Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.</font><p>
</td>
		</tr>
</table>
</BODY>
</HTML>

<!-- END FOOTER -->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -