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

📄 196-198.html

📁 WindowsCE.[Essential Windows CE Application Programming].Jon Wiley & Son.zip
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<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=7//-->
<!--PAGES=196-198//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="192-196.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="199-201.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>The <I>propid</I> member is of type CEPROPID, which is defined as a LONG. The low word of <I>propid</I> identifies the data type of the property. The high word is an application-defined index. Typically this index is used to represent the zero-based index of the property in the record. The low word must be one of the values listed in Table 7.2.</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 7.2</B> CEPROPID Data Type Specifiers
<TR>
<TH WIDTH="40%" ALIGN="LEFT">VALUE
<TH WIDTH="60%" ALIGN="LEFT">DATA TYPE
<TR>
<TD>CEVT_BLOB
<TD>A CEBLOB structure
<TR>
<TD>CEVT_FILETIME
<TD>A FILETIME structure
<TR>
<TD>CEVT_I2
<TD>A 16-bit signed integer
<TR>
<TD>CEVT_I4
<TD>A 32-bit signed integer
<TR>
<TD>CEVT_LPWSTR
<TD>A null-terminated Unicode string
<TR>
<TD>CEVT_UI2
<TD>A 16-bit unsigned integer
<TR>
<TD>CEVT_UI4
<TD>A 32-bit unsigned integer
</TABLE>
<P>As an example, the phone list application defines the property identifiers of the phone list database record properties in this way:
</P>
<!-- CODE //-->
<PRE>
   //First define the indices of the properties within the record
   #define PL_LASTNAME_INDEX   0
   #define PL_FIRSTNAME_INDEX  1
   #define PL_PHONENUMBER_INDEX 2
   #define PL_DEPT_INDEX     3*
   //Next define the CEPROPID values of the record properties
   #define PL_LASTNAME \
     (MAKELONG(CEVT_LPWSTR,PL_LASTNAME_INDEX))
   #define PL_FIRSTNAME \*
     (MAKELONG(CEVT_LPWSTR, PL_FIRSTNAME_INDEX))
   #define PL_PHONENUMBER \
     (MAKELONG(CEVT_LPWSTR,PL_PHONENUMBER_INDEX))
   #define PL_DEPT \
     (MAKELONG(CEVT_I2, PL_DEPT_INDEX))
</PRE>
<!-- END CODE //-->
<P>The second member of the CEPROPVAL structure, <I>wLenData</I>, is not used. The <I>wFlags</I> member is used to define a set of special property flags. This member is typically set to 0. We will discuss the other values of this member and their meanings later when discussing reading and writing database records.</P>
<P>The most interesting of the CEPROPVAL members is the <I>val</I> member. As the name indicates, this member contains the actual data associated with the particular record property. This member is of type CEVALUNION, a union defined as follows:</P>
<!-- CODE //-->
<PRE>
   typedef union _CEVALUNION
   &#123;
     short iVal;
     USHORT uiVal;
     long lVal;
     ULONG ulVal;
     FILETIME filetime;
     LPWSTR lpwstr;
     CEBLOB blob;
   &#125; CEVALUNION;
</PRE>
<!-- END CODE //-->
<P>Each of the members of this union corresponds to one of the data type identifiers of the <I>propid</I> member of the CEPROPVAL structure (see Table 7.2). The member of this union that you would use when setting the value of a particular record property would thus depend on the data type specified in that property&#146;s property identifier. For example, to set the first name property of a phone list database record, the phone list application would do the following:</P>
<!-- CODE SNIP //-->
<PRE>
   CEPROPVAL cepvFirstName;
   cepvFirstName.propid = PL_FIRSTNAME;
   cepvFirstName.val.lpwstr = TEXT("Some Name");
</PRE>
<!-- END CODE SNIP //-->
<P>Or to set the department number property:
</P>
<!-- CODE SNIP //-->
<PRE>
   CEPROPVAL cepvDeptNum;
   cepvDeptNum.propid = PL_DEPT;
   cepvDeptNum.val.iVal = 12; //i.e., the appropriate dept number
</PRE>
<!-- END CODE SNIP //-->
<P>These examples are meant only to demonstrate the use of the CEPROPVAL <I>val</I> member. As we&#146;ll see later, applications typically define an array of CEPROPVAL structures to represent the entire record to be read or written.</P>
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">Creating the Database</FONT></H3>
<P>Windows CE databases are created using the <I>CeCreateDatabase</I> function. The syntax of <I>CeCreateDatabase</I> is:</P>
<!-- CODE SNIP //-->
<PRE>
   CeCreateDatabase(lpszName, dwDbaseType, wNumSortOrder,
     rgSortSpecs);
</PRE>
<!-- END CODE SNIP //-->
<P>The first parameter is the Unicode string name of the database to be created. This name can be up to 32 characters long (including the null terminator). Database names that exceed this limit are truncated. The next parameter is the database type identifier. This value is defined by the application to distinguish one type of database from another. For example, let&#146;s say that an application needs to manage the phone list databases for three different companies, as well as the payroll databases for those same companies. This application could define the following database types:
</P>
<!-- CODE SNIP //-->
<PRE>
   #define DB_TYPE_PHONE_LIST   0
   #define DB_TYPE_PAYROLL    1
</PRE>
<!-- END CODE SNIP //-->
<P>Each of the phone list databases could be created with a database type identifier DB_TYPE_PHONE_LIST, and the payroll databases could be created with type identifier DB_TYPE_PAYROLL. The application could then use the database type identifier to distinguish between the different types of databases, for example when enumerating all databases on a Windows CE device.
</P>
<P>The <I>wNumSortOrder</I> indicates the number of sort orders allowed for the database. This is a fancy way of saying how many record properties the database can use as sort keys. The final parameter is an array of SORTORDERSPEC structures defined in more detail below.</P>
<P>The <I>CeCreateDatabase</I> function returns the object identifier of the database if the creation is successful. If unsuccessful, <I>CeCreateDatabase</I> returns zero.</P>
<P>If we can create a database, we must also be able to delete it. To delete a database, simply call <I>CeDeleteDatabase</I>. This function takes one parameter, the object identifier of the database to be deleted.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="192-196.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="199-201.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 + -