📄 221-225.html
字号:
<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=""> <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=8//-->
<!--PAGES=221-225//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch07/221-220.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="225-231.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 8<BR>Using the Windows CE Registry
</FONT></H2>
<P><BIG><BIG>T</BIG></BIG>hus far in our investigation of Windows CE persistent storage, we have considered two mechanisms typically used for storing large amounts of data. The Windows CE file system is a useful way to store large amounts of data, such as documents, in a hierarchical directory structure. Windows CE databases are useful for storing and managing large numbers of data records such as phone list or contact information.</P>
<P>But what if your application has the need for small amounts of persistent storage? It would be overkill to create an entire database or directory structure just to keep track of a few numbers or strings.</P>
<P>Additionally, a particular database or file format is generally intended for use by the application that creates it. Applications generally are not prevented from accessing data in files or databases created by other applications. But to do so requires knowledge of a specific file format or database record design.</P>
<P>The Windows CE registry provides a generic mechanism for storing persistent information that is intended to be available on a system-wide basis. The registry has a simple hierarchical structure, and provides an application programming interface that makes it easy for any application on a Windows CE device to find information available to the entire system.</P>
<P>One of the most familiar examples is the use of the registry by Microsoft’s Component Object Model (COM) technology. COM uses the registry as a way to, among other things, make information about COM objects available to all interested parties.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>AFTER COMPLETING THIS CHAPTER YOU WILL KNOW HOW TO …</B>
<DL>
<DD><B>Program the Windows CE registry</B>
<DD><B>Use the Remote Registry Editor</B>
</DL>
<HR></FONT>
</BLOCKQUOTE>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">Registry Basics</FONT></H3>
<P>Although it is part of the Windows CE object store, the registry is different from the Windows CE file system and databases. The registry does not store data as objects with unique object identifiers. The registry functions do not access data in the registry via a particular CEOID associated with a registry entry. The only similarity between the registry and these other two object store entities is that they are all used to store persistent data in object store RAM.
</P>
<P>The Windows CE registry is organized as a hierarchical set of <I>keys</I>, <I>subkeys</I>, and <I>values</I>. Keys and subkeys are the registry analog of directories in the Windows CE file system. Keys can contain one or more subkeys. Keys and subkeys can contain one or more values, which are used to store the actual data contained in the registry.</P>
<P>Much as Windows CE databases can be assigned an application-specific database type, registry keys can be given a <I>class name</I>. Such a class name can be used to provide further distinction between registry keys.</P>
<P>At the root of the Windows CE registry hierarchy are three <I>primary keys</I>: HKEY_LOCAL_MACHINE, HKEY_CLASSES_ROOT, and HKEY_CURRENT_USER. Every registry subkey and value falls under one of these three primary keys.</P>
<P>Just as Windows CE represents files and databases as handles, there is also a handle data type for registry keys called HKEY. Many of the registry functions identify the key or subkey on which they are to operate by means of an HKEY handle.</P>
<P>The Windows CE registry can be used to store data of the following types: binary, DWORD, null-terminated Unicode string, Unicode symbolic link, or resource. The various registry functions refer to these data types by the symbols shown in Table 8.1. We’ll see these data type values in the context of the various registry functions later.</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 8.1</B> Registry API Data Type Symbols
<TR>
<TH WIDTH="40%" ALIGN="LEFT">SYMBOL
<TH WIDTH="60%" ALIGN="LEFT">MEANING
<TR>
<TD>REG_BINARY
<TD>Binary data.
<TR>
<TD>REG_DWORD
<TD>A 32-bit number.
<TR>
<TD VALIGN="TOP">REG_DWORD_LITTLE_ENDIAN
<TD>A 32-bit number in little endian format, i.e., the most significant byte of each word is the high-order byte.
<TR>
<TD VALIGN="TOP">REG_DWORD_BIG_ENDIAN
<TD>A 32-bit number in big endian format, i.e., the most significant byte of each word is the low-order byte.
<TR>
<TD VALIGN="TOP">REG_EXPAND_SZ
<TD>A null-terminated Unicode string that contains unexpanded references to environment variables, such as %PATH%.
<TR>
<TD>REG_SZ
<TD>A null-terminated Unicode string.
<TR>
<TD VALIGN="TOP">REG_MULTI_SZ
<TD>An array of null-terminated Unicode strings. The array itself is terminated by two null characters.
<TR>
<TD>REG_LINK
<TD>A Unicode symbolic link.
<TR>
<TD>REG_RESOURCE_LIST
<TD>A device driver resource list.
<TR>
<TD>REG_NONE
<TD>No defined data type.
<TR>
</TABLE>
<P><FONT SIZE="+1"><B>Viewing the Windows CE Registry</B></FONT></P>
<P>The Remote Object Viewer allows you to view files and databases on a Windows CE device or in the emulation environment; similarly, the Windows CE Toolkit provides a Remote Registry Editor, which allows you to explore the registry in the emulation environment or on an actual Windows CE device. It also allows you to create, delete, and modify registry subkeys and values.
</P>
<P>You access the remote Registry Editor by choosing the Remote Registry Editor menu option from the Tools menu in the Microsoft Developer Studio development environment (Figure 8.1).</P>
<P><A NAME="Fig1"></A><A HREF="javascript:displayWindow('images/08-01.jpg',391,324 )"><IMG SRC="images/08-01t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/08-01.jpg',391,324)"><FONT COLOR="#000077"><B>Figure 8.1</B></FONT></A> Opening the Remote Registry Editor.</P>
<P>The Remote Registry Editor looks and works much like the Windows NT Registry Editor called regedit. In fact, the remote Registry Editor has all of the functionality of regedit and more.
</P>
<P>When the Remote Registry Editor first appears, it contains two tree view nodes in the left-hand pane, labeled My Computer and My Emulation (Figure 8.2). The My Computer item is the root of all of the registry keys on the Windows NT machine on which you are running Microsoft Developer Studio. You can browse these keys and delete, add, or modify subkeys and values just as you would with regedit. Any changes that you make to the registry keys under My Computer are made in the registry of your Windows NT host machine.</P>
<P><A NAME="Fig2"></A><A HREF="javascript:displayWindow('images/08-02.jpg',538,293 )"><IMG SRC="images/08-02t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/08-02.jpg',538,293)"><FONT COLOR="#000077"><B>Figure 8.2</B></FONT></A> The Remote Registry Editor.</P>
<P>The My Emulation tree view node is the root of all the registry keys contained by your Windows CE emulation object store. You can therefore make any modifications you like to your emulation registry by editing the subkeys and values under My Emulation.
</P>
<P>The Remote Registry Editor makes it easy for you to modify the Windows CE emulation registry manually. You will very often find yourself wanting to modify the registry in this way, particularly when debugging applications that use the registry. It would be a bit tedious if you could only edit the registry programmatically.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch07/221-220.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="225-231.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> | <a href="/contactus.html"><font color="#006666">Contact Us</font></a> | <a href="/aboutus.html"><font color="#006666">About Us</font></a> | <a href="http://www.earthweb.com/corporate/privacy.html" target="_blank"><font color="#006666">Privacy</font></a> | <a href="http://www.itmarketer.com/" target="_blank"><font color="#006666">Ad Info</font></a> | <a href="/"><font color="#006666">Home</font></a></b>
<br><br>
Use of this site is subject to certain <a href="/agreement.html">Terms & Conditions</a>, <a href="/copyright.html">Copyright © 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 + -