`
`
`
`r
`
`Page 00002
`
`Page 00002
`
`
`
`
`Windows ({ Developer's "and book
`
`~ ..
`
`~
`
`.
`.,
`. ...
`... ..
`..... .
`·, .. . . .
`.
`..
`.. :;. : ,:
`..
`. :
`..
`
`..
`
`Page 00003
`
`
`
`Page 00004
`
`Page 00004
`
`
`
`Windows® ({ Developer's Uandbook!M
`
`Terence A. ~oggin
`with
`David L. Heskett and
`Jason M. Maclean
`
`~ w
`
`SYBEX"
`
`San Francisco • Paris • Dusseldorf • Soest • London
`
`Page 00005
`
`
`
`Associate Publisher: Gary Masters
`Contracts and Licensjng Mani:tK"er: Krbtine O'Callaghrm
`Acquisitions & Developmental Editor: Brenda Frink
`Editor: Sally Engel fried
`Project Editor: 13ronwyn Shone Erickson
`Technical Editor: John Pstdk
`Book Designer: Kris Warr~nburg
`Graphic Illustrator: Tony Janick
`Electronic Publishing Specialist: Robin Kibby
`Proofreade1•: judy Weiss
`Project Team Leader: Sh;mnon Murphy
`Indexer: Meg Fortune McDonnell
`Companion CD: Ginger Warner
`Cover Designer: Design Site
`Cover Photographer: The Image Bank
`
`Developer's Handbook is a trademark ofSYI3EX Inc.
`
`The HP Jornada is a trademark o r registered trademark of
`Hewlett-Packard Company, copyright ([)1')99.
`
`The Casio E-11 is a trademark or registered tradema rk of Casio,
`Incorporated, copyright (\)1lJ9Y.
`
`The Casio PA-2400 and Casio PA-2500 are trademarks or regis(cid:173)
`tered trademarks of Casio Business Solutions Group, copyright
`0 199'1.
`
`TRADEMARKS: SYI3EX has a ttempted throughout this book to
`distinguish proprietary trademarks from descriptive terms by fol(cid:173)
`lowing the capitalization style used by the manufacturer.
`
`The author and publisher haw made their best efforts to prepare
`this book, and the content is based upon final release software
`whenever possible. Portions of the manuscript may be based
`upon pre-release versions supplied by software manufacturer(s).
`The author and the publisher make no representation or war(cid:173)
`ranties of any kind with regard to the completeness or accuracy
`of the contents herein and accept no liability of any kind includ(cid:173)
`ing but not limited to performance, merchantability, fitness for
`any particular pmpose, or any losses or damages of any kind
`caused or alleged to be caused directly or indirectly from this book.
`
`Copyright 11)1999 SYBEX Inc., 1151 Marina Village Parkway,
`Alameda, CA 94501. World rights reserved. No part of this publi(cid:173)
`cation may be stored in a retrieval system, transmitted, or repro(cid:173)
`duced in any way, including but not limited to photocopy,
`photograph, magnetic or other record, without the prior agree(cid:173)
`ment and written permission of the publisher.
`
`Library of Congress Card Number: 99-61299
`LSt:lN : 0-7R2 L-2414-3
`
`Manuf<1ctured in the United States of America
`10987654321
`
`Page 00006
`
`
`
`Software License Agreement: Terms and
`Conditions
`The media and/or any online materials accompanying this book
`that are available now or in the future contain programs and/or
`text files (the "Software") to be used in connection with the book.
`SYBEX hereby grants to you a license to use the Software, subject
`to the terms that follow. Your purchase, acceptance, or use of the
`Software will constitute your acceptance of such terms.
`
`The Software compilation is the property of SYBEX unless other(cid:173)
`wise indicated and is protected by copyright to SYBEX or other
`copyright owner(s) as indicated in the media files (the "Owner(s)").
`You are hereby granted a single-user license to use the Software
`for your personal, noncommercial use only. You may not repro(cid:173)
`duce, sell, distribute, publish, circulate, or commercially exploit
`the Software, or any portion thereof, without the written consent
`of SYI:lEX ilntl the specific copyright owner(s) of any component
`software included on this media.
`
`In the event that the Software or components include specific
`license requirements or end-user agreements, statements of condi(cid:173)
`tion, disclaimers, limitations or warranties ("End-User License"),
`those End-User Licenses supersede the terms and conditions
`herein as to that particular Software component. Your purchase,
`acceptance, or use of the Software will constitute your acceptance
`of such End-User Licenses.
`
`l:ly purchase, use or acceptance of the Software you further agree
`to comply with all export laws and regulations of the United States
`as such laws and regulations may exist from time to time.
`
`Software Support
`Components of the supplemental Software and any offers associ(cid:173)
`ated with them may be supported by the specific Owner(s) of that
`material but they are not supported by SYBEX. Information regard(cid:173)
`ing any available support may be obtained from the Owner(s)
`using the information provided in the appropt·iate read.me files or
`listed elsewhere on the media.
`
`Should the manufacturer(s) or other Owner(s) cease to offer sup(cid:173)
`port or decline to honor any offer, SYBEX bears no responsibility.
`This notice concerning support for the Software is provided for
`your information only. SYBEX is not the agent or principal of the
`Owner(s), and SYBEX is in no way responsible for providing any
`support for the Software, nor is it liable or responsible for any sup(cid:173)
`port provided, or not provided, by the Owner(s).
`
`Warranty
`SYBEX warrants the enclosed media to be free of physical defects
`for a period of ninety (90) days after purchase. The Software is not
`available from SYBEX in any other form or media than that enclosed
`herein or posted to www.sybcx.co111. If you discover a defect in the
`media during this warranty period, you may obtain a replacement
`
`of identical form<lt at no charge by sending the defective media,
`postage prepaid, with proof of purchase to:
`
`SYBEX Inc.
`Customer Service Department
`1151 Marina Village Parkway
`Alameda, CA 94501
`(51 0) 523-8233
`Fax: (510) 523-2373
`e-mail: info@sybex.com
`WEB: HTTP:/ / WWW.SYBEX.COM
`
`After the 9ll-day period, you can obtain replacement media of
`identical format by sending us the defective disk, proof of pur(cid:173)
`chase, and a check or money order for $10, payable to SYBEX.
`
`Disclaimer
`SYBEX makes no warranty or representation, either expressed or
`implied, with respect to the Software or its contents, quality, per(cid:173)
`formance, merchan tability, or fitness for a particular purpose. In
`no event will SYBEX, its d istributors, or dealers be liable to you or
`any other party for direct, indirect, special, incidental, consequen(cid:173)
`tial, or other damages arising out of the use of or inability to use
`the Software or its contents even if advised of the possibility of
`such damage. In the event that the Software includes an online
`update feature, SYBEX further disclaims any obligation to provide
`this feature for any specific duration other than the initial posting.
`
`The exclusion of implied warranties is not permitted by some
`states. Therefore, the above exclusion may not apply to you. This
`warranty provides you with specific lega l rights; there may be
`other rights that you may have that vary from state to state. The
`pricing of the book with the Software by SYBEX reflects the alloca(cid:173)
`tion of risk and limitations on liability contained in this agreement
`of Terms and Conditions.
`
`Shareware Distribution
`This Software may contain various programs that are distributed
`as shareware. Copyright laws apply to both shareware and ordi(cid:173)
`nary commercial software, and the copyright Owner(s) retains all
`rights. If you try a shareware program and continue using it, y ou
`are expected to register it. Individual programs differ on details of
`ti·ial periods, registration, and payment. Please observe the require(cid:173)
`ments stated in appropriate files.
`
`Copy Protection
`The Software in whole or in part may or may not be copy-pro(cid:173)
`tected or encrypted, However, in all cases, reselling or redistribut(cid:173)
`ing these files without authorization is expressly forbidden except
`as specifically provided for by the Owner(s) therein.
`
`Page 00007
`
`
`
`Page 00008
`
`Page 00008
`
`
`
`I dedicate this book to Tim, my brother, my editor,
`and my best friend. I could not have written this
`book without you. Your hard work means more to
`me than I could ever put into words.
`Thank you.
`
`Page 00009
`
`
`
`ACKNOWL{DGM£NTS
`
`There are a great many people who made this book possible, and I would like
`to thank them all.
`
`First, thanks to Ann Goldmann, Brooke Richardson, and Suzanne Lamberton of
`Waggoner-Eddstrom for helping me on a project that was a little outside of the
`norm. You really helped me to get started and I want you to know that I appreci(cid:173)
`ate it very much.
`
`To Barry Raymond, Eric Drew, and Norman Hills of Casio's Vertical Markets
`Division: Thank you for sharing with me some of the unique and exciting projects
`you've created with Windows CE. Your real-world perspective was extremely
`helpful and got me started off on the right track.
`
`To Bob Smith, Pat Carrasco, and Cheryl Balbach of Casio New Jersey. It was a
`pleasure working with you, and I hope you're pleased with the result.
`
`To Scott Crossen, thank you for creating the excellent RAPI source code for Del(cid:173)
`phi, and thank you for graciously allowing me to reprint it here in this book.
`
`To Helen Chan and Chris Yien of Hewlett-Packard, thank you for your help in
`completing this book and making sure it contained the very latest information
`about the newest CE devices.
`
`To everyone at Microsoft who made time to help out: to David Streams, thank
`you for the initial interview and your insight and advice on what to cover; to
`Amy Stuhlberg, thank you for stepping in and helping me get in touch with the
`right people; to Scott Horn and Cyra Richardson, thank you for your advice on
`what developers want to learn about; to Doug Yip, thank you for putting me in
`touch with the right people; to Brian Sherrell, thank you for answering all of m y
`questions and helping me sort through the issues; to Scott Henson, thank you for
`working with me on the promotion of the book before it was even finished; and
`to Prashant Sridharan, thank you for making sure I had the latest versions of the
`toolkit. I am indebted to all of you.
`
`Page 00010
`
`
`
`To Shirley Macbeth and Liam Cavanagh of Sybase; Neil Shepherd, Jay Botelho,
`and Etienne Viellard of Oracle; and Larry Lundgren and John Deurbrouck (who
`wrote the Raima section of Chapter 12) of Raima Corporation, thank you all for
`providing samples of your products and write-ups of their capabilities.
`
`To Andy Mallinger and Michael Snyders of InstallShield; to Yuko Tanaka, Mike
`Nydam, Mike Krautkramer, and Dan Spalding of Proxim, Inc.; to Peter Phillips
`of Socket Communications; and to Tom Carpenter and Mark Gentile of Odyssey
`Software, thank you for all of your hard work and for making sure that I was able
`to include your products in the book. I think- and I hope you do, too-that the
`book is much better for it.
`
`To everyone at Sybex-to Peter Kuhns, who got this whole thing started, thank
`you for believing in me and in the book. To Brenda Frink and Gary Masters,
`thank you for taking over and for being so patient. To Bronwyn Erickson, thank
`you for keeping me organized and focused. Thanks also to Shannon Murphy,
`Project Team Leader; Robin Kibby, Electronic Publishing Specialist; Kristine
`O'Callaghan, Contracts and Licensing Manager; and Liz Paulus, Production
`Technician.
`
`To Sally Engelfried, thank you for doing a great job editing my work. Thank
`you for being flexible and really working with me on some of the early issues.
`What more can I say but thank you?
`
`To David Heskett and Jason MacLean, thank you for helping me to complete
`this book. You guys really pulled through for me, and I appreciate that. You both
`created some great code, and I hope when it's all done you're as proud of it as I
`am. But more important than that for me, I wanted to let you know that it was
`great to work this closely with you both after such a long absence. It's just not the
`same without you around.
`
`To John Psuik, my technical editor, I've said it before, and I'll say it again:
`Thank you. Your knowledge, your attention to detail, and your generosity were
`invaluable. I look forward to working with you on future projects.
`
`Thanks also to Fred Wilf, for your excellent advice.
`
`Last but most, thanks to my dad, who first suggested that I write.
`
`Page 00011
`
`
`
`CONT{NTS AT A GLANC{
`
`Introduction
`
`PART I
`
`Inside the Core O~erating S~stem
`
`Chapter 1: What Does CE Do for Me?
`Chapter 2: The Three Commandments of Writing for CE
`Chapter 3: To C or Not to C?
`Chapter 4: CE' s Structured Storage
`
`PART II
`
`Mastering the Develo~er's Tools
`
`Chapter 5: CE Toolkit for Visual C++
`Chapter 6: Yes, It's Possible-MFC onCE!
`Chapter 7: Real MFC Applications Ported to CE
`Chapter 8: Visual Basic Toolkit for CE
`Chapter 9: A Real VB Application Converted to CE
`
`PART Ill
`
`Advanced To~ics
`
`Chapter 10: RAPI: How the Outside World Talks to CE
`
`Chapter 11: How CE Talks to the Outside World
`Chapter 12: Third-Party Database Engines
`
`Chapter 13: Windows CE Case Studies and Cost Analysis
`
`xix
`
`1
`
`3
`41
`
`75
`113
`
`142
`
`145
`
`173
`
`197
`
`225
`
`243
`
`278
`
`281
`305
`
`335
`361
`
`Page 00012
`
`
`
`PART IV
`
`Finishing Touches
`
`Chapter 14: Distributing Your CE Application
`
`Chapter 15: Microsoft's Logo Requirements
`
`PARTV
`
`Appendices
`
`Appendix A: The C Runtime Library Functions of Windows CE
`
`Appendix B: The CE 2.0 API
`
`Index
`
`373
`
`375
`
`405
`
`432
`
`436
`
`472
`
`585
`
`Page 00013
`
`
`
`Page 00014
`
`Page 00014
`
`
`
`TABL( 0~ CONT£NTS
`
`Introduction
`
`1 What Does CE Do for Me?
`What Is CE, Anyway?
`Why CE Isn't Windows 98/NT
`What Is Unique to CE?
`CE Devices
`Palm-Size PC Devices
`Handheld PC Devices
`Handheld PC I Pro Devices
`Other Devices
`Accessories for CE
`Ethernet/Networking Solutions
`Bar Code Readers
`Summary
`
`2 The Three Commandments of Writing for CE
`The First Commandment: Your Application Must Use the Unicode
`Character Set
`Declaring Strings Using Unicode Types Rather Than Char Types
`Using Unicode Strings for All Text Literals
`Choosing the Correct RTL Functions for Unicode Strings
`Equipping Your Program to Handle Two Types of Text Files
`The Second Commandment: Your Application Must Be
`Low-Memory Aware
`Keeping the Size and Number of Static Variables to a Minimum
`Keeping the EXE File Size Low
`Checking the Return Result of Memory Allocation
`Mass-Allocating Your Application's Memory
`Handling the WM_HIBERNATE Message
`
`X1X
`
`1
`
`3
`4
`5
`10
`12
`12
`25
`27
`34
`36
`36
`38
`38
`
`41
`
`42
`43
`46
`47
`48
`
`55
`56
`56
`57
`58
`60
`
`Page 00015
`
`
`
`xiv
`
`Table of Contents
`
`The Third Commandment: Know Your Form Factor!
`The UI of the Application Should Be Tailored to the Device
`Maintaining a Single Codebase Is Nearly Impossible
`Creating Your Own Conditional Defines
`Creating a H.untime Platform Detector
`Summary
`
`3 To C or Not to C?
`Finding Substitute Functions
`calloc()
`MoveToEx() I LineTo()
`WM_RBUTTONDOWN
`Changing the Program's Logic: try .. catch and Exceptions
`Writing Your Own Functions
`FILE*
`fop en()
`fclose()
`fgetc()
`fputc()
`£gets()
`fputs()
`fread()
`£write()
`fprintf()
`fscanf()
`fseek()
`Summary
`
`4 CE's Structured Storage
`The Regis try
`Proper Uses of the CE Registry
`Improper Uses of the CE Registry
`The Windows CE Database Engine
`Differences between CE's Database Engine and Familiar
`Database Engines
`Similarities between CE' s Database Engine and Familiar
`Database Engines
`The CE Database Engine API
`Summary
`
`61
`62
`67
`69
`70
`73
`
`75
`77
`77
`77
`78
`79
`80
`81
`83
`88
`89
`90
`92
`94
`95
`96
`97
`99
`108
`110
`
`113
`115
`116
`116
`119
`
`119
`
`122
`135
`141
`
`Page 00016
`
`
`
`Table of Contents
`
`xv
`
`PART II
`
`Mastering the Developer's Tools
`
`5 CE Toolkit for Visual C++
`Using VC++ to Develop for Windows CE
`The Windows CE Toolkit for VC++
`The Platform SDKs
`MFC vs. SDK-Style Coding
`Storage Space
`Ease of Development
`A Sample SDK-Style Application
`Displaying a List of Running Tasks
`Switching to One of the Tasks
`Closing an Application
`One Last Snag: Keeping the List of Tasks Current
`Summary
`
`6 Yes, It's Possible-MFC onCE!
`New Classes for CE
`CCeSocket
`CCeDBEnum
`CCeDBProp
`CCeDBRecord
`CCeDBDatabase
`Modified Classes
`Classes That Lost Functionality
`Classes That Gained Functionality
`Missing Classes
`Summary
`
`7 Real MFC Applications Ported to CE
`The Shopping List Application
`Mechanical Issues of Porting
`Toolbars and Status Bars
`Printing Support
`The Grid
`Optimizing for CE
`One Final Surprise
`Summary
`
`142
`
`145
`146
`146
`158
`160
`161
`161
`162
`163
`166
`166
`168
`170
`
`173
`174
`175
`176
`176
`179
`179
`191
`192
`192
`194
`194
`
`197
`198
`201
`201
`206
`207
`217
`220
`222
`
`Page 00017
`
`
`
`xvi
`
`Table of Contents
`
`8 Visual Basic Toolkit for CE
`The Windows CE Toolkit for VB
`The Application Templates
`The Debugger
`The Runtime Files
`The Control Manager
`The ActiveX Control Pack
`The Standard VBCE Controls
`The Setup Wizard
`Changes in the Visual Basic Language
`A Sample Application
`Summary
`
`9 A Real VB Application Converted to CE
`The Application: International ATM
`Porting the ATM Application: Not As Simple As It Looks
`Mechanical Issues of Porting
`The Optional Features
`Re-Adding the WAY Files
`The Country and Flag Bitmaps
`Optimizing for CE
`Eliminating a Form
`Eliminating Optional Controls and DLLs
`Optimizing the Code Itself
`Summary
`
`PART Ill
`
`Advanced Topics
`
`10 RAP I: How the Outside World Talks to CE
`What Is RAPI, Anyway?
`General RAPT Management Functions
`System Information Functions
`Registry Access Functions
`File Access Functions
`Database Access Functions
`Miscellaneous Shell and System Functions
`A Sample RAPI Application
`Using Other Languages
`Summary
`
`225
`226
`226
`228
`229
`230
`231
`235
`236
`237
`238
`240
`
`243
`244
`246
`249
`262
`262
`266
`270
`270
`274
`274
`276
`
`278
`
`281
`282
`283
`285
`287
`288
`292
`292
`293
`298
`302
`
`Page 00018
`
`
`
`Table of Contents
`
`xvii
`
`11 How CE Talks to the Outside World
`What's in the Box?
`The Hardware Aspect
`The Software Aspect
`Summary
`
`12 Third-Party Database Engines
`Raima's RDM/ CE for Data Storage
`Network and Relational Data Models
`Introducing HpcLadr
`Putting RDM to Work
`Sybase's Adaptive Server Anywhere
`Sybase's Adaptive Server Anywhere Sample Application
`Oracle Lite Introduction
`Oracle Lite for Windows CE
`Comparison of Features
`Summary
`
`13 Windows CE Case Studies and Cost Analysis
`Study 1: Inventory Management System
`The Technical Issues
`Cost
`Conclusion of Study 1
`Study 2: Insurance Agents in the Field
`Solution
`The Technical Issues
`Cost
`Conclusion of Study 2
`Study 3: Choosing Your Development Machine
`Solution
`Cost
`Conclusion of Study 3
`Summary
`
`PART IV
`
`Finishing Touches
`
`14 Distributing Your CE Application
`Creating Help for Windows CE
`The Two Types of CE Help Files
`
`305
`306
`306
`308
`333
`
`335
`337
`337
`338
`341
`341
`342
`347
`348
`356
`358
`
`361
`362
`362
`365
`366
`366
`367
`367
`368
`370
`370
`370
`372
`372
`372
`
`373
`
`375
`376
`377
`
`Page 00019
`
`
`
`xviii
`
`Table of Contents
`
`The Single-File Help System
`The Multiple-File Help System: The HTC File
`The Multiple-File Help System: The HTP File
`Getting the Application to the User 's Device
`The Cab Wizard Option
`InstallShield for Windows CE
`Summary
`
`15 Microsoft's Logo Requirements
`What Is the Logo Program and Why Should You Care?
`So What?
`The Logo Requirements
`Ins tall a tion
`UI Requirements
`Functionality Requirements
`File-Handling Requirements
`Summary
`
`PARTV
`
`Appendices - - - - - -- - -
`A The C Runtime Library Functions of Windows CE
`
`B The CE 2.0 API
`
`Index
`
`378
`383
`386
`389
`390
`400
`403
`
`405
`406
`407
`408
`409
`413
`425
`429
`431
`
`432
`
`436
`
`472
`
`585
`
`Page 00020
`
`
`
`INTRODUCTION
`
`The war on the desktop is over.
`
`Well, okay ... maybe it isn't truly over, but the focus has definitely shifted a bit.
`
`Suddenly, as if out of nowhere, there appeared a whole new class of Windows-
`based machines, unlike anything we'd ever seen before. These were the very first
`Handheld PC (HPC) devices. Soon after, there was a version 2.0 release of Win(cid:173)
`dows CE, and with it, a greater sophistication of devices, as well as a greater vari(cid:173)
`ety of form factors and features.
`
`But unlike other flavors of Windows, CE is a brand new Windows operating
`system, built entirely from scratch. There is no old DOS core- but then again,
`there's also no backwards compatibility. Instead, CE is a wild mixture of new and
`old elements. On the one hand, developers can write programs for it using a good
`portion of the Win32 API. On the other hand, it's amazingly compact and has
`some very tight memory requirements. Likewise, it's a version of Windows that
`runs on several different CPUs, yet it has a look and feel that's very close to that
`of desktop-based Windows.
`
`Developing CE applications is also a strange mix of elements. One moment
`you're reminded that you're writing applications for a tiny device with a small
`grayscale screen, and the next moment you think it's just like Windows 98 or NT.
`
`Yes, CE does have some limitations. But in this book, we'll be treating these lim(cid:173)
`itations simply as challenges to be dealt with. Here we'll develop all kinds of
`applications designed to show off everything that you need to know in order to
`be a successful CE developer. We'll cover everything from new common controls
`to memory limitations to dealing with the Unicode character set.
`
`Who Should Read This Book
`
`This book was written with the experienced developer in mind. Perhaps you've
`been hearing or seeing a lot about Windows CE, and you've decided that you'd
`like the inside scoop with as little hassle as possible. Or perhaps you've already
`
`Page 00021
`
`
`
`xx
`
`Introduction
`
`decided CE is the way to go and you just need a way to dive right in. Or maybe
`you're interested in CE for some other reason completely.
`
`In any event, this book assumes that you are an experienced Windows devel(cid:173)
`oper, with at least the ability to read C/C-H-, Visual Basic, or Delphi source code.
`This book assumes that you know the basics of Windows programming tasks
`such as creating a window, adding items to a list box, etc.
`
`Instead of re-emphasizing the basics, this book concentrates on the differences
`between Windows 98 I NT and Windows CE. It spells out exactly what you need
`to know to navigate the ins and outs of Windows CE.
`
`What This Book Contains
`
`This book uses numerous examples in C/C++, Visual Basic, and even Delphi to
`demonstrate Windows CE programming techniques. There is a sample program
`for each technique discussed in the book, and the source code for each of these
`programs can be found on the CD.
`
`The book is organized into five major sections:
`
`Part I: Inside the Core Operating System
`
`Part II: Mastering the Developer 's Tools
`
`Part III: Getting the Most Out of Windows CE
`
`Part IV: Finishing Touches
`
`Part V: Appendices
`
`Part 1: Inside the Core Operating System
`The main purpose of this section is to lay out exactly what Windows CE offers
`developers, both in terms of hardware and software. You'll jump right into code
`in Chapter 1, learning about the different hardware platforms and how to work
`with what each one offers. For example, how do you use a CE device to output
`graphics to a VGA monitor?
`
`Page 00022
`
`
`
`Introduction
`
`xxi
`
`Chapter 2 details some of the main differences between Windows 98/NT pro(cid:173)
`gramming and Windows CE programming. Some of the topics covered here
`include getting your application to look good on all of the CE form factors, work(cid:173)
`ing with the Unicode character set, and memory allocation issues.
`
`Chapter 3 highlights some of the functions and features missing from Win(cid:173)
`dows CE and demonstrates solid techniques for replacing or working around the
`missing functionality. For instance, when you're developing for certain CE plat(cid:173)
`forms, you don't have a stdi o. h available. Of course, this makes it very difficult
`to port existing code ... unless, of course, you recreate the missing file-access func(cid:173)
`tions of stdi o. h as we do in this chapter!
`
`In the last chapter of this section, Chapter 4, the book introduces a feature of
`CE not available on any other operating system: a built-in database engine. Win(cid:173)
`dows CE is one of the few-if not the only-operating systems to offer a database
`engine as part of the operating system itself, and this chapter shows you how to
`make the best use of it.
`
`Part II: Mastering the Developer's Tools
`In this section, we look at how to best utilize the tools Microsoft makes available
`for us. Specifically, Chapter 5 discusses the Windows CE toolkit for Visual C++.
`You'lllearn how to deal with common problems encountered with the toolkit. In
`addition, the chapter analyzes the tradeoffs between SDK-style C programming
`and MFC programming for CE.
`
`In Chapter 6, we'll look at the differences between MFC on Windows 98/ NT
`and MFC on Windows CE. Specifically, we'll look at some new classes to deal
`with CE's Database Engine and its communications model. And, as you may
`have guessed, there are also a few classes that don't exist under CE, and some
`that have undergone changes.
`
`In Chapter 7, we'll see exactly what it takes to port a real Windows 98/ NT MFC
`application to Windows CE-based MFC. We'll cover issues ranging from the
`basic port to printing support.
`
`In Chapter 8, we explore the Windows CE toolkit for Visual Basic. There are
`some areas where the toolkit for Visual Basic can present some real surprises for
`anyone who's used to working with Visual Basic for Windows 98/NT, and this
`chapter looks at both the surprises and features.
`
`Page 00023
`
`
`
`xxii
`
`Introduction
`
`In Chapter 9, just a w clid in Chapter 7, we'll port a real Windows 98/NT
`Visual Basic applicati n to Windows CE. We'll explore all aspects of what has to
`happen before we can take a working desktop VB application and produce a
`solid VB application.
`
`Part Ill: Getting the Most Out of Windows CE
`In this section, we take full advantage of the more advanced features of the CE
`operating system. Specifically, in Chapter 10, we look at how desktop machines
`and desktop applications can communicate with Windows CE devices. Using the
`Remote API (or RAPI), desktop applications can access a surprisingly rich set of
`features on the CE device. What's more, we'll even see how RAPI programs can
`be written in any desktop application development language-even a non(cid:173)
`Microsoft product like Borland's Delphi can talk to CE devices, thanks to RAPI!
`
`In Chapter 11, we'll explore all forms of Windows CE communications. CE
`devices have a multitude of possible ways to communicate with the outside
`world, and this chapter looks at all of them: the serial port, theIR port, modems,
`PCMCIA devices, and Winsock connections!
`
`In Chapter 12, we look at ways to extend the usefulness of Windows CE devices
`by examining the features of some third-party CE Data bas Engines. Oracle, Sybase,
`and Raima Corporation offer the three leading third-pa1·ty database engines avail(cid:173)
`able for Windows CE. Each of these vendor l1as created a sample application and
`a brief article describing the application and/ or the features of their engine.
`
`Chapter 13 offers something few programming books do: pseudo case studies.
`Based on real case studies but modified to be general enough to apply to anyone,
`these case studies present a view of what it takes to put together a full Windows CE(cid:173)
`based solution for your clients, whether you're a consultant or a part of a corpora(cid:173)
`tion's IS department.
`
`Part IV: Finishing Touches
`In this section, we look at some additional touches you might want to put on
`your application. In Chapter 14, we look at what it takes to create a help system(cid:173)
`whether it's one simple file or multiple files-for your CE application. Al o, we'U
`look at what it takes to create a simple setup program for yom application, either
`by hand or using a third-party tool.
`
`Page 00024
`
`
`
`Introduction
`
`xxiii
`
`Then, in Chapter 15, we'll explore what the Windows CE Logo Program is all
`about and how it can help you. We'll see how, in addition to ensuring that your
`application has a standard consistent look and feel, the Logo Program can help
`you market your CE application much more effectively.
`
`Part V: Appendices
`To round out the book, we've included two of the most useful appendices possi(cid:173)
`ble. Appendix A details all of the C runtime library functions guaranteed to be
`available for all CE versions/ platforms. Using this appendix as a guide, you can
`safely pick and choose which runtime functions to use if you're compiling an
`application for more than one CE version/platform. As an added benefit, the
`header file and a simple example are provided for each and every function.
`
`Appendix B takes a similar approach to the Windows CE API. In this appendix,
`we detail every single API call that is unique to Windows CE 2. For every func(cid:173)
`tion, we list the header file, a description of the function's purpose, and a sample
`demonstrating the use of the function.
`
`Perhaps the best feature of this section is that both of these appendices are pro(cid:173)
`vided on the CD in PDF form, so that you can easily load each appendix, browse
`to the function you want, and copy /paste the function's example right into your
`own code.
`
`About the Examples
`The majority of the examples in this book were written in Microsoft Visual C++ 6
`with the Windows CE Toolkit for VC++ 6. There are also examples that were cre(cid:173)
`ated in Visual Basic 5 I 6, with the appropriate version of the Windows CE toolkit
`for Visual Basic. Also, in Chapters 10 and 14, there are two samples developed
`using Borland's Delphi product.
`
`As of this writing, Microsoft has the only C / C++ based compiler that builds
`applications for the Windows CE operating system. Although there is talk on the
`newsgroups about a possible GNU compiler port, no such product has yet been
`released.
`
`Page 00025
`
`
`
`Page 00026
`
`Page 00026
`
`
`
`Inside the Core
`Operating System
`
`I CHAPTER 1: What Does CE Do for Me?
`
`I CHAPTER 2: The Three Commandmewts of Writing for CE
`
`I CHAPTER 3: To C or Not to C
`
`I CHAPTER 4: CE'5 Structured Storage
`
`Page 00027
`
`Page 00027
`
`
`
`Page 00028
`
`Page 00028
`
`
`
`CHAPT[R
`0 N {
`
`What Does CE Do for Me?
`
`• What is CE, Anyway?
`
`• Why CE isn't Windows 98/NT
`
`• Features Unique to CE
`
`• CE Devices: Shapes, Sizes, and What You Need to Know
`About Each One
`
`• CE Accessories
`
`Page 00029
`
`
`
`4
`
`Chapter 1 • What Does CE Do for Me?
`
`In a promotional video sent out by Mlnosoft late last year, Harel Kodesh of
`Micr oft's Consumer Appliances Group was quoted as sayil1g, "CE was built
`with on thirlg in mind, and that is powering information appli.ances." These infor(cid:173)
`mation appliances give pe ple such a degr -e of fre dam and power in their per(cid:173)
`sonal and bLISin s lives that they've created an instant market for new software.
`
`A larg part of what makes these devic s so powerful is that they're not just
`organjzers or wizards. Yes, every CE devi e comes with pocket versions of Out(cid:173)
`look, but you can run real applications on the devices, too.
`
`In many ways, Windows CE puts a virtual desktop computer in the palm of
`your hand or in your pocket. It's that capability that makes Windows CE a
`"shrunken head" version of Windows 98/NT, as we'll see in this chapter. We call
`CE a shrunken head version of Windows because you have to work with far less
`memory than you are used to, smaller screens, fewer colors, etc.
`
`The questions we'll be answering in this chapter are, "What doe CE do for
`m ?'' and, "How can I get my programs port d to CE?" To answer them, we'll
`look at the different types of CE devices and what each one offers in terms of
`functionality. In many cas s, you'll be surprised t find out just how powerful a
`CE d vice can be. De pite their smaU sizes, their CPUs r.ival thos we have in our
`desktop computers.
`
`We'll also be 1 oking at some of the CE-compatible hardware you can add to your
`application to make it a more complet CE solution. For instance, what if you need
`to add some kh1d of sec ndary storage to your device because 8MB just isn't
`enough? That said, let's get right into it with a look at the different device types.
`
`What Is CE, Anyway?
`
`Windows CE is a stripped-down version of Windows 98/ NT that's been engi(cid:173)
`neered specifically for small, low-resource, portable devices such as:
`
`• The Palm-size PC
`
`• The Handheld