`
`UNVR
`
`MU
`
`II
`
`Robert Bur
`
`Samsung Exhibit 1031 Page 00001
`
`
`
`SEm1..CW
`CD—ROM
`
`B8
`
`Page 00002
`
`
`
`UNIVERSITY
`
`LIBRARIES
`
`GMU
`
`3277 011672792
`
`Page 00003
`
`
`
`Essential
`WindowsR CE
`Application
`Programming
`
`Robert Burdick
`
`Wiley Computer Publishing
`
`NEW YORK
`
`John Wiley
`SINGAPORE
`CHICHESTER WEINHEIM BRISBANE
`
`Sons Inc
`TORONTO
`
`Page 00004
`
`
`
`Publisher Robert
`
`Ipsen
`
`Editor Marjorie Spencer
`
`Assistant Editor Margaret Hendrey
`
`Managing Editor Brian Snapp
`
`Electronic Products Associate Editor Mike Sosa
`Composition NK Graphics
`
`Text Design
`
`Designations used by companies to distinguish their products are often claimed as trade
`instances where John Wiley
`marks In all
`Sons Inc is aware of claim the product names
`appear in initial capital or ALL CAPITAL LETTERS Readers however
`the appro
`should contact
`priate companies for more complete information regarding trademarks and registration
`
`This book is printed on acid-free paper
`
`Copyright
`
`1999 by Robert Burdick All rights reserved
`
`Published by John Wiley
`
`Sons Inc
`
`Published simultaneously in Canada
`
`No part of this publication may be reproduced stored in retrieval system or transmitted in
`any form or by any means electronic mechanical
`recording scanning or
`photocopying
`otherwise except as pennitted under Sections 107 or 108 of the 1976 United States Copyright
`Act without either the prior written permission of the Publisher or authorization
`through
`payment of the appropriate per-copy fee to the Copyright Clearance Center 222 Rosewood
`Drive Danvers MA 01923 978 750-8400 fax 978 750-4744 Requests
`to the Publisher
`for
`permission should be addressed to the Permissions Department John Wiley
`Sons Inc 605
`212 850-6011 fax 212 850-6008 E-Mail
`Third Avenue New York NY 10158-0012
`PERMREQ WILEY.COM
`
`This publication is designed to provide accurate and authoritative
`information in regard to
`the subject matter covered It
`is sold with the understanding
`the publisher is not
`services
`in professional
`If professional advice or other expert assistance is
`engaged
`required the services of
`competent professional person should be sought
`
`that
`
`Library of Congress Cataloging-in-Publication
`
`Data
`
`Burdick Robert 1965
`Essential Windows CE application programming Robert Burdick
`cm
`ISBN 0-471-32747-6 pbk
`alk paper
`Microsoft Windows computer ifie
`Computers
`QA76.76.063B856
`005.4469dc2l
`
`Operating systems
`
`98-50484
`CIP
`
`Title
`
`1999
`
`Printed in the United States of America
`
`10
`
`Page 00005
`
`
`
`LR7
`.7 r71
`
`r13
`
`To my wife Katy for urging me ever onward
`
`Page 00006
`
`
`
`Page 00007
`
`Page 00007
`
`
`
`Acknowledgments
`Introduction
`
`Part
`
`Chapter
`
`Windows CE Application Programming
`Fundamentals
`
`Getting Started with Windows CE
`What Is Windows CE
`Windows CE Programming Tools
`Before We Move On
`Now Lets Get to Work
`
`Chapter
`
`Windows CE Application Template
`
`What Is Window Anyway
`
`Creating Windows
`The Windows CE Application Entry Point
`
`The Message Loop
`The Template Application
`
`Concluding Remarks
`
`Chapter
`
`Controls and Dialog Boxes
`
`Programming Child Controls
`Programming Common Controls
`
`DialogBoxes
`The Windows CE Common Dialogs
`Common Dialog Programming
`Concluding Remarks
`
`Chapter
`
`Menus and the Windows CE Command Bar
`Repeat Myself When under Stress
`The Command Bar Control
`
`Windows CE Menu Basics
`
`xi
`
`xiii
`
`13
`
`17
`
`19
`
`20
`
`27
`
`31
`
`34
`
`37
`
`40
`
`41
`
`41
`
`45
`
`48
`
`59
`
`61
`
`68
`
`69
`
`70
`
`71
`
`74
`
`Page 00008
`
`
`
`Creating Command Bar
`Inserting Menu into Command Bar
`Adding Controls to Command Bar
`Adding Tool Tips to Command Bar Buttons
`Other Command Bar Functions
`Using Accelerators in Windows CE Applications
`Using the Window Menu
`The Complete Wmdows CE Menu API
`The Complete CMDBAR Sample Application
`Concluding Remarks
`
`Chapter
`
`Windows CE Common Controls
`
`The Month Calendar Control
`
`The Date Time Picker Control
`
`Rebar Controls
`
`Command Bands
`
`Concluding Remarks
`
`Part II
`
`Windows CE Persistent Storage
`
`Objct Identifiers
`
`The CeOidGetlnfo Fimction
`Viewing the Windows CE Object Store
`
`Chapter
`
`Working with the Windows CE File System
`The File System Explorer Application
`
`File Handles
`
`File Attributes
`
`Searching for Files
`Creating and Opening Files and Directories
`
`Reading and Writing File Data
`Copying and Renaming Files and Directories
`Deleting Files and Directories
`Flash Cards and Persistent Storage
`
`Concluding Remarks
`
`Chapter
`
`Windows CE Databases
`
`The Phone List Application
`Programming Wmdows CE Databases
`
`77
`
`78
`
`79
`
`86
`
`87
`
`88
`
`91
`
`93
`
`103
`
`103
`
`105
`
`107
`
`123
`
`134
`
`140
`
`143
`
`145
`
`146
`
`146
`
`149
`
`153
`
`154
`
`159
`
`160
`
`162
`
`165
`
`171
`
`178
`
`180
`
`180
`
`183
`
`185
`
`186
`
`191
`
`Page 00009
`
`
`
`Internal Representation of Record Properties
`
`Creating the Database
`Sorting and the SORTORDERSPEC
`Opening and Closing the Database
`
`Writing and Reading Database Records
`
`Searching for Records
`
`Database Enumeration
`
`Database Notifications
`
`The Contacts Database
`
`Concluding Remarks
`
`Chapter
`
`Using The Windows CE Registry
`
`Registry Basics
`Creating And Opening Registry Keys
`Reading and Writing Registry Values
`Enumerating Registry Keys and VaJues
`Deleting Registry Keys and Values
`
`The Registry Sample Application
`Concluding Remarks
`
`195
`
`197
`
`198
`
`201
`
`203
`
`208
`
`211
`
`213
`
`213
`
`218
`
`221
`
`222
`
`229
`
`231
`
`236
`
`239
`
`240
`
`241
`
`Part Ill
`
`Windows CE User Interface Programming
`
`243
`
`What We Will Learn
`
`Chapter
`
`Owner Draw Controls and Custom Window Classes
`
`Why Focus on Owner Draw Buttons
`The Example Application
`The Anatomy of Windows CE Control
`How Owner Draw Buttons Are Different
`
`The Kiosk Application
`Concluding Remarks
`
`Chapter 10
`
`The Windows CE Custom Draw Service
`
`Custom Draw Notification
`Responding to Custom Draw Notifications
`Other NMCUSTOMDRAW Info Structures
`
`Real Example
`Concluding Remarks
`
`245
`
`247
`
`247
`
`249
`
`250
`
`251
`
`258
`
`273
`
`275
`
`277
`
`281
`
`284
`
`285
`
`288
`
`Page 00010
`
`
`
`Chapter 11 Designing Windows CE Custom Controls
`The Example Custom Control
`Custom Control as Dynamic Link Library
`Packaging
`Initializing the DLL in the Client Application
`Implementing the Custom Button Control
`The Complete Sample Application
`Concluding Remarks
`
`Chapter 12
`
`The HTML Viewer Control
`Overview of the HTML Viewer Control
`
`The Sample Application
`Preparing to Use the HTML Viewer Control
`Creating HTML Viewer Controls
`Displaying HTML Formatted Text
`
`Handling Hyperlinks
`
`Displaying Inline Images
`HTML Viewer Control Messages and Notifications
`
`Chapter 13 Palm-size PC Input Techniques
`The Rich Ink Control
`
`Programming the Rich Ink Control
`Programming the Palm-size PC Navigation Buttons
`Adding Voice Input to Palm-size PC Applications
`
`Real Example
`Concluding Remarks
`
`Part IV
`
`Desktop Connectivity and Memory Issues
`
`Chapter 14 Windows CE Data Synchronization
`The Sample Code
`
`ActiveSync Technology Overview
`The Synchronization Process from the 50000 Foot Level
`
`Registering ActiveSync Service Providers
`Desktop Service Provider Data Model
`
`Desktop Service Provider
`Initializing
`Reconstructing Folders and Items
`
`Enumerating Objects
`
`289
`
`290
`
`291
`
`298
`
`300
`
`310
`
`311
`
`313
`
`314
`
`317
`
`318
`
`318
`
`319
`
`321
`
`325
`
`327
`
`329
`
`330
`
`332
`
`341
`
`348
`
`352
`
`354
`
`357
`
`359
`
`360
`
`361
`
`366
`
`369
`
`374
`
`376
`
`377
`
`380
`
`Page 00011
`
`
`
`Reporting Desktop Data Store Changes
`
`Transferring the Data
`
`Notifying the Service Manager
`
`Programming Device Service Providers
`
`Conflict Resolution
`
`Concluding Remarks
`
`Chapter 15 Other Desktop Connectivity Topics
`The Remote API
`
`RAPI Sample Application
`Using Remote API Functions
`Windows CE File Filters
`
`The Sample File Filters
`
`Registering File Filters
`Concluding Remarks
`
`Chapter 16 Memory and Power Management
`The Sample Application
`Windows CE Memory Basics
`Allocating Memory
`Wmdows CE Memory Mapped Files
`Handling Low Memory Conditions
`The GetSystemPowerStatusEx Function
`
`Concluding Remarks
`
`Whats on the CD-ROM
`Index
`
`386
`
`388
`
`392
`
`394
`
`399
`
`402
`
`403
`
`404
`
`405
`
`405
`
`409
`
`411
`
`417
`
`419
`
`421
`
`422
`
`422
`
`426
`
`433
`
`442
`
`443
`
`445
`
`447
`
`451
`
`Page 00012
`
`
`
`Page 00013
`
`
`
`started working on this book back in April of 1998 when
`wrote the
`number of people have contributed
`original proposal Since that time
`in various ways to its successful completion
`
`Great thanks go to Marjorie Spencer and Margaret Hendrey and Brian
`Snapp at John Wiley and Sons Their thoughtful and professional assis
`tance in every aspect of preparing the manuscript of this book are deeply
`appreciated Pam Masara of John Wiley and Sons also deserves many
`thanks for encouraging me to contact Marjorie about
`heartfelt
`the idea
`for this book Thanks also go to Rob Vermeulen and Peter van der Lin
`den both accomplished writers in their own right for their advice and
`encouragement
`On the technical front special
`thanks go to Martin Heller for his thor
`ough critique of the manuscript Thanks also to John Ruley for his
`review of my original proposal and his suggestions for how to improve
`the focus of the book must also thank everyone at TJpperCase Soft
`ware for their patience and understanding during my writing of this
`book would particularly like to thank Frank Halasz and Kim McCall for
`the opportunity to work for them part time while spending the majority
`of my time writing and Tom Zurkan for helping me sort out various
`issues would also like to thank Tor Ainundson of Navitel
`ActiveSync
`Communications for his help with various hardware issues Former
`Navitel compatriot Dianna Tai also deserves thanks for her input on data
`synchronization
`
`Thanks also go to several people at Philips Mobile Computing Group
`David Hargis and James Beninghaus provided me with some great oppor
`tunities to write Palm-size PC applications for the Philips NINO Also
`Michael Croot Benjamin Beasley and Sathish Damodaran have been
`in helping me meet my deadlines
`instrumental
`thanks to Mom and Dad for all of their love
`must of course add special
`also want to thank my mother-in-law
`and moral support over the years
`
`xi
`
`Page 00014
`
`
`
`forget John and Kat
`cannot
`Olga Disney for making the best polenta
`rina Staten for giving me the key to their house in Cannel that week in
`April where the outline for this book was conceived
`
`Thanks also go to my two cats Boots and Luigi for their company on
`many late nights while working on this book Jumping up on the key
`board aside thanks for the support Any last minute typos are entirely
`their fault
`
`debt of gratitude to my wife Katy
`owe
`Finally and most importantly
`could have
`for all of her support and encouragement There is no way
`done this without you Thanks for enduring with me all of the stress
`occasional depression and of course the jubilation that went along with
`getting this done
`
`Page 00015
`
`
`
`he Windows CE operating system has been available to application pro-
`grammers for over two years Independent
`software vendors have been
`writing applications for platforms such as the Hanciheld PC ever since
`Windows CE was born At the same time original equipment manufac
`turers have been designing and implementing all kinds of new devices
`based on the operating system But despite the growth of the operating
`system and the number of software developers writing appilcations for
`handful of books on the subject of Windows CE
`there are still only
`it
`programming
`
`My interest in writing this book comes from over two years of Windows
`CE programming experience during which
`have been involved in
`number of Windows CE development efforts
`am writing this book out
`have gained from these
`desire to share with readers the insights
`of
`experiences
`
`As the market for mobile and handlield computing devices continues to
`grow Windows CE will continue to change The features present
`in
`Windows CE today may not be there tomorrow Windows CE features
`will be shaped by the demands of the users of the devices powered by
`the operating system
`
`part of Windows CE This
`But certain core technologies will always be
`features of Windows CE programming
`book is
`guide to the essential
`
`How This Book Is Organized
`
`book is organized into four parts which focus on the following Win
`dows CE application programming topics
`Windows CE programming fundamentals
`Windows CE persistent storage
`
`XIII
`
`Page 00016
`
`
`
`xiv
`
`Part
`
`User interface programming techniques
`Desktop connectivity memory and power management
`
`Part
`
`of the book covers Windows CE prograLmrnirig fundamentals and
`describes the architecture of the Win
`contains five chapters Chapter
`dows CE operating system The various Windows CE subsystems are
`look at how to use some of the
`described In addition Chapter
`takes
`development tools available for writing Windows CE applications The
`sample session in which you learn how to
`takes you through
`chapter
`build Windows CE application for emulation as well as for
`real hard
`ware platform
`
`covers the main ingredients of Windows CE application
`Chapter
`Through the example of
`generic template application the chapter
`introduces the concepts of the Windows CE entry point registering win
`dow classes writing window procedures and creating windows It also
`points out some of the fundamental differences between Windows CE
`windows and windows created for desktop W1n32 platforms
`
`discusses the fundamentals of programming Windows
`Next Chapter
`introduces the basic con
`CE controls and dialog boxes The chapter
`cepts you need to use Windows CE child and common controls It also
`covers how to program modal and modeless dialogs arid how to write
`fmishes with
`and use dialog procedures Chapter
`discussion of pro
`gramming the Windows CE common dialogs
`
`Chapter
`devoted to
`
`bar control
`
`covers Windows CE menus The majority of the chapter
`discussion of Windows CE command bars The command
`is sri essential part of using menus in Windows CE applica
`
`is
`
`tions
`
`concludes with more detailed discussion of programming the
`Part
`Windows CE common controls In particular Chapter
`covers the
`month calendar control
`the date time picker control rebar controls and
`command bands
`
`Part II
`
`Part II of this book is dedicated to Windows CE persistent storage The
`three chapters in this part are your resource for learning how to program
`the various features of the Windows CE object store
`
`Page 00017
`
`
`
`covers using the Windows CE file system and how to program
`Chapter
`the file system API You will
`learn about using files and directories as
`well as how to access storage cards attached to Windows CE devices
`The concepts of this chapter are made clear with the Windows CE File
`System Explorer sample application
`
`learn how
`Chapter discusses Windows CE database techno1ogy You will
`to create custom databases for your applications and how to read and
`write database records You will also learn how to search for database
`records and how to sort databases In addition Chapter
`introduces the
`Windows CE contacts database
`
`The last chapter of Part II covers the Windows CE registry Chapter
`shows you how to use the registry for persistent storage of small
`amounts of information when
`complete database or directory struc
`ture is not necessaiy
`
`Part III
`
`on various Windows CE user interface program
`Part III concentrates
`ming techniques An entire book could easily be devoted to this subject
`The five chapters in this section cover some of the more important and
`common user interface programming subjects
`
`begins the discussion by introducing the concept of owner
`Chapter
`draw controls With specific examples of progranuning owner draw but
`tons the chapter provides an overview of how Windows CE owner draw
`controls can be used to customize the appearance of your applications
`This chapter also covers the use of offscreen bitmaps Chapter 10
`expands on the owner draw concept with its treatment of the Windows
`CE custom draw service
`
`Chapter 11 shows you how to take complete control of the appearance
`and behavior of your controls by describing how to create Windows CE
`valuable review of how to
`custom controls This chapter also provides
`program and use dynamic llnk libraries
`Chapter 12 is about using the Windows CE HTML viewer control
`shows you how to use this control to add HTML viewing capabilities to
`your Windows CE applications
`
`It
`
`Finally Chapter 13 introduces various nontraditional Windows CE input
`techniques In the context of progranmîing applications for the Palm-size
`PC this chapter shows you how to program the rich ink control and how
`
`Page 00018
`
`
`
`to add voice recording capability to applications using the voice recorder
`control Chapter 13 also describes how to take advantage of the Palm-size
`PC navigation buttons
`
`Part IV
`
`The last part of this book discusses programming some of the desktop
`connectivity features provided by the Windows CE operating system
`This section is invaluable if you are interested in writing Windows CE
`applications that can share data with desktop PCs
`
`Chapter 14 covers the ActiveSync
`technology for data synchronization
`learn how to program ActiveSync
`You will
`service providers for both
`desktop PC and Windows CE device
`
`Chapter 15 shows you how to use the remote application programming
`interface or RAPI
`in order to allow your desktop applications to access
`Windows CE devices This chapter also covers file filter programming
`
`The last chapter of the book introduces Windows CE memory manage
`ment concepts Chapter 16 also discusses Windows CE power consider
`ations
`
`Who Should Read This Book
`
`This book is intended primarily for readers with some Windows pro
`gramming experience It assumes that you are familiar with the basic
`components of desktop Windows application It assumes that you have
`written applications for Windows
`Windows 95 or Windows 98 It
`also assumes that you already have some experience with Windows
`graphics programming topics such as the Graphics Device Interface
`GDI functions
`However you do not need to be Windows expert to use this book for
`your Windows CE programming needs In fact the emphasis in this book
`is on programming Windows CE at the application programming inter
`face API level This book is perfectly suited therefore for program
`mer with experience using the Microsoft Foundation Classes MFC but
`whose understanding of how the underlying API works is
`
`bit rusty
`
`This is why for example
`topics such as window procedures
`cover
`message loops and dialog box programming early in the book Many
`
`Page 00019
`
`
`
`XVII
`
`Windows programmers successfully write applications with MFC but
`do not really understand how that class library works And since Win
`dows CE is for many reasons not particularly well suited to MFC this
`book will provide many intermediate level Windows programmers with
`thorough understanding of the internal workings of Windows CE
`
`Experienced Windows programmers will also fmd this book valuable
`because it discusses features specific to Windows CE application pro
`gramming Many of the advanced topics in this book such as data syn
`chronization or programming the remote API may be unfamiliar to the
`most experienced Windows NT or Windows 98 programmer
`This book is intended then for intermediate level and advanced Win
`dows programmers interested in writing Windows CE applications
`Advanced
`readers may fmd that
`they want
`to skip the chapters that
`cover subjects they are familiar with from programming desktop Win
`dows applications For example chapters covering Windows CE dialog
`box programming custom controls or the Windows CE file system can
`safely be skipped by advanced readers However
`is worth pointing out
`that although many Windows CE concepts are similar to their Windows
`NT or Windows 98 counterparts there are often subtle differences spe
`cific to Windows CE programming More experienced programmers will
`therefore fmd all of the chapters of this book useful
`
`it
`
`With few exceptions all of the examples in this book and all of the code
`samples on the companion CD-ROM are written in
`is only used
`for some of the code required for the ActiveSync
`service providers in
`Chapter 14 and for the file filter examples of Chapter 15
`
`Tools You Will Need
`
`desktop PC running Win
`is assumed that you have
`To use this book it
`dows NT version 4.0 or later with Microsoft Developer Studio Visual
`version 5.0 or later It also assumes that you have installed the Windows
`CE Toolkit for Visual
`version 2.0 or later
`
`The companion CD provides
`number of sample applications illustrat
`ing the programming concepts discussed in this book Read the appen
`dix Whats on the CD-ROM to fmd out more about
`if you are
`it
`interested in running any of these on Windows CE device such as
`Handheld PC or Palm-size PC it
`is assumed that you have installed Win-
`
`Page 00020
`
`
`
`dows CE Services on your desktop PC This book also assumes that you
`are familiar with concepts such as connecting the device to the PC and
`copying files to the device
`
`DEVELOPMENT MUST BE DONE ON WINDOWS NT
`
`on Windows NT The emulation
`Your Windows CE applications must be developed
`environment only works under Windows NT and the Windows CE Toolkits and SDKs
`are only supported for Windows NT
`
`Before We Begin
`
`lot of material However no single book can possible
`This book covers
`subject as vast as Windows CE programming It
`discuss all aspects of
`is my hope that this book will become your primary reference for under
`standing the most essential features of Windows CE programming
`
`on those subjects that are most funda
`As such this book concentrates
`mental to Windows CE As with any software product Windows CE will
`see features come and go But the fundamental building blocks on which
`Windows CE applications are based are sure to be around for
`long time
`is the goal of this book to introduce you to these core Win
`to come It
`dows CE programming concepts
`
`Page 00021
`
`
`
`ONE
`
`Windows CE Application
`Programming Fundamentals
`
`thorough understanding Windows CE programming requires
`firm
`the fundamentals We therefore begin our exploration of Win
`grasp
`discussion of the core Win
`lows CE application programming with
`dows CE topics
`
`brief look at the overall architecture of the Windows
`\Ve start with
`typical Win
`CF operating system We continue with the anatomy of
`dows CE application Next programming application building blocks
`such as Windows CE controls and dialog boxes are covered
`
`look at how menus are included in Windows
`contJnlLes with
`Part
`from how
`CE applications We will see that
`this is very different
`menus are added to Windows 98 or Windows NT applications The
`Windows CE command bar control
`is presented in this discussion
`description of programming Windows CE common
`closes with
`Part
`
`solid under
`you will have
`After completing the chapters in Part
`standing of the basic principles required to write more complex Win
`dows
`application programming
`
`Page 00022
`
`
`
`Page 00023
`
`
`
`.1
`
`Getting Started
`with Windows CE
`
`this chapter we take
`brief look at the architecture of the Windows
`CE operating system We also discuss some of the software develop
`ment tools available to help you write Windows CE applications
`Is Windows CE
`
`What
`
`Windows CE is
`compact modular 32-bit operating system designed
`for use on devices with small memory requirements Windows CE is
`very similar in design to its larger desktop cousin Windows NT Win
`dows CE is multitasking multithreaded operating system like Win
`dows NT It includes most of the user interface features of Windows NT
`so that software developers can take advantage of most users familiar
`ity with Windows applications
`Storage on Windows CE devices is
`combination of random access
`memory RAM and read-only memory ROM Devices can also
`include expansion flash memory storage cards for additional storage
`space PCMCIA cards can be added to many devices and Windows
`CE provides full support
`for such cards
`Since storage is all memory based the contents of the Windows CE file
`system is stored in RAM The operating system and all applications
`
`Page 00024
`
`
`
`which ship with Windows CE devices are in ROM The ROM software
`components are run in place instead of being paged into RAM so that
`they run faster
`Windows CE application programmers get
`huge productivity boost
`because Windows CE is based on the Win32 API This means that pro
`grammers who are familiar with programming for traditional Win
`dows platforms like Windows NT can begin programming Windows
`CE applications with very little additional
`training Certainly there are
`features that are unique to Windows CE But understanding tradi
`big advantage when moving to the
`tional Windows programming is
`Windows CE operating system
`
`Architectural Considerations
`
`Windows CE consists of seven subsystems Each of these subsystems is
`further broken down into smaller components The GWE subsystem
`including the window
`for example consists of smaller components
`manager and the dialog manager The seven Windows CE subsystems
`are
`
`kernel
`
`The Graphics Windowing and Event Subsystem GWES
`The object store including the file system
`The OEM Adaptation Layer OAL
`The device driver layer
`The communication APIs
`
`Custom shells and the Internet Explorer
`
`The Kernel
`
`is similar to the kernel in Windows NT It uses
`The Windows CE kernel
`the same thread and process model as Windows NT It supports the
`same file formats as Windows NT Additionally Windows CE uses
`virtual memory model similar to Windows NT You can write Windows
`CE applications that share memory across multiple processes using
`memory mapped files
`The Windows CE kernel also implements the object manager As is the
`case with Windows NT windows GDI objects such as brushes and
`
`Page 00025
`
`
`
`bitmaps files and all other such objects are manipulated by applica
`lions through object handles The handles as well as the underlying
`objects they correspond to are managed by the object manager
`
`The Graphics Windowing and Event Subsystem
`
`Windows CE has combined the user and GDI components into one
`subsystem This subsystem the Graphics Windowing and Event Sub
`system is sometimes abbreviated as GWES or even GWE
`Windows CE behavior such as creating window painting window
`string resource is handled somewhere within the code of
`or loading
`this subsystem All of the Windows CE child controls such as buttons
`list boxes and the like are implemented in GWES
`GWES also contains the event manager This is where the Windows CE
`messaging capabilities are implemented
`
`The Object Store
`
`Random access memory in Windows CE device is divided into two
`is program memory The other part contains the Win
`sections The first
`dows CE object store The object store contains the Windows CE file
`system and the registry The object store also contains Windows CE
`databases such as the Contacts database and custom databases created
`by applications
`
`The OEM Adaptation Layer
`The OEM adaptation layer or OAL consists of all of the pieces of soft
`ware that an original equipment manufacturer OEM must implement
`to port Windows CE to new hardware
`
`new class of Windows CE products
`If you are interested in creating
`such as
`point-of-sale terminal for ordering parts at the local auto
`repair shop you need to get Windows CE to run on your custom hard
`ware The OAL is where you customize the interrupt service routines
`and hardware interfaces that allow hardware to communicate with
`Windows CE
`Programming the OEM adaptation layer is one of the many aspects of
`Windows CE embedded systems programming As this subject
`
`Page 00026
`
`
`
`deserves an entire book of its own it
`is not covered in this book which
`is devoted to application programming
`
`The Device Driver Layer
`
`This layer of the Windows CE operating system contains all of the driv
`ers for peripherals that are included with
`particular device These
`might include flash memory card drivers video drivers and keyboard
`like the OAL belongs in an
`drivers Detailed coverage of this subject
`embedded systems programming book
`
`The Communication APIs
`
`Windows CE includes many of the commi.mication APIs that you might
`be familiar with from Windows NT For example sockets serial corn
`mimication TAPI and the WinliNet APIs are all supported under Win
`dows CE
`One of the most important features of many Windows CE devices is
`their ability to share data with desktop PC Windows CE therefore
`technology ActiveSync allows application pro
`supports ActiveSync
`grammers to write service providers for synchronizing application-
`specific data between Windows CE devices and desktop computers
`Additionally there is file filter support for transferring files between
`platforms
`
`Custom Shells and the Internet Explorer
`OEMs can use the Windows CE shell component to write their own cus
`tom shells for their devices For example if you do not want
`the stan
`dard Handheld PC shell you can write your own
`Windows CE also supports
`
`version of the Internet Explorer
`
`Windows CE Modularity
`features of Windows CE from the OEM point of view
`One of the nicest
`is the modularity of the operating system Each of the various subsys
`tem components can be added or removed as needed If you are design
`that does not need any of the Windows CE child controls
`product
`ing
`for example you can remove them from the ROM operating system
`image that runs on your hardware This allows OEMs to shrink the
`
`Page 00027
`
`
`
`memory footprint of the operating system by removing any compo
`nents that are not needed for
`particular product
`The SYSGEN tool that ships with the Windows CE Platform Builder
`makes this possible When OEMs license Windows CE they get all of
`the operating system component libraries They must however build
`their own operating system image
`
`file called CESYSGEN.BAT that
`Part of this process involves writing
`specifies which component libraries to include in the image The SYS
`GEN tool then links those pre-compiled libraries into the operating
`system image
`
`Windows CE Programming Tools
`
`Microsoft designed Windows CE with existing Windows programmers
`in mind We have already discussed how Windows CE is based on the
`Win32 API Programmers can also use many of the same programming
`tools that they are already familiar with
`This is because Microsoft Developer Studio can be used for writing
`and debugging Windows CE applications Emulators for the various
`Windows CE platforms allow developers to write and debug applica
`desktop PC The Windows CE Toolkit includes utilities
`tions on
`for
`allowing the Microsoft Developer Studio debuggers to remotely debug
`applications rumiing on Windows CE hardware Developers can there
`fore begin writing and debugging Windows CE applications without
`new set of development tools
`learning
`
`Sample Session
`To demonstrate the Windows CE programming tools lets see how to
`sample Windows CE application We will build the TEM
`build
`PLATE.EXE application for the Handheld PC emulation environment
`Then we will see how to build the same application for real Hand
`heldPC hardware and download it to
`device The project files for this
`application can be found on the companion CD under
`\Samples\
`template
`
`Building for Emulation
`
`The first step in building Windows CE application for any target is to
`open the workspace file for that application Choose the Open Work-
`
`Page 00028
`
`
`
`II
`
`II
`
`II
`
`Controls
`
`oys Controls
`
`Boxes
`
`Boxes
`
`ombo Boxes
`
`ombo Box St
`
`Figure 1.1
`
`The Open Workspace menu option
`
`space option from the Microsoft Developer Studio File menu Figure
`1.1 From the Open Workspace dialog find and open the file TEM
`PLATE.DSW Figure 1.2
`
`Ii-
`
`template
`
`template dsw
`
`Workspaces .ds mdp
`
`Figure 1.2 Opening the Workspace file
`
`Page 00029
`
`
`
`J2WCi86em Debug
`Win32 Release
`NV1n32 Debug
`yVin32 WOE MIPS Release
`V/in32 WOE MIPS Debug
`Win32 WOE SH Release
`Win32 WOE SHDebug
`
`Figure 1.3
`
`Selecting
`
`target build configuration
`
`You must now specify which configuration to build the application for
`selection from the combo box shown in Fig
`This is done by making
`ure 1.3 You can specify whether to build TEMPLATE.EXE
`for the
`debug emulation environment Or you can build the release or debug
`versions of the application for any of the processors for which you
`have installed compilers As we want to build for debug emulation
`select the Win32 WCE x86em Debug option
`If you have installed more than one Windows CE Platform SDK
`ond combo box will be included in the Developer Studio toolbar
`to build for For this example make
`which lets you select the product
`sure you pick Handheld PC version
`
`sec
`
`WHAT IF DONT SEE THE CONFIGURATION COMBO Box
`
`If the configuration combo box does not appear somewhere in the Developer Studio
`the Customize.. option from the
`toolbar you may need to add it manually Select
`Tools menu Then click on the Commands tab From the Category combo box select
`include the configuration combo box Simply drag it to
`Build The Buttons group will
`your toolbar and drop it where you want it
`
`Now that you have specified the configuration to build build the
`application by choosing the Rebuild All option from the Build menu
`The application will compile and link During the link phase the
`Handheld PC emulation environment will start up Figure 1.4 This
`real Handheld PC shell
`simulates
`
`Page 00030
`
`
`
`iñh1k1LE
`
`Development Tools
`
`figure 1.4
`
`The Handheld PC emulation environment
`
`Now you can run and debug the application just as you would any
`ot