개발이야기2007. 8. 6. 12:53

 

Windows CE Developers FAQ

Welcome to the CEGadgets Windows CE Developer FAQ page! Here you will find answers to common (and not so common) Windows CE development questions. This FAQ tries to avoid basic Windows CE issues (what is Windows CE, what is activeSync) and instead serves as a technical document discussing Windows CE specific development issues. Also, this FAQ avoids embedded specific issues, and focuses more on application development.

If you have something you want to add, or find a problem, send a note to faq@cegadgets.com explaining the problem or addition. I will update the FAQ ASAP and give you credit for it as well. Thanks!

This FAQ was last updated 27-Mar-01. Also, notice that new and updated items show in a separate section (as well as in the main contents list). Items will remain in the new/updated section for one week.

1. General
1.1 Why should I write software for Windows CE?
1.2 What does the CE in Windows CE stand for?
1.3 I want to learn about Windows CE development. Where should I start?
1.4 What books are available for Windows CE developers?
1.5 What are some other developer related Windows CE websites?
1.6 Where can I find information on DevCon 99?
1.7 I need to learn CE in a hurry - can I take a class?
1.8 Things to consider before you design that new Windows CE application.
1.9 I want to develop using Visual C++. What do I need?
1.10 I want to develop using Visual Basic. What do I need?
1.11 What other development tools are available for windows CE?
1.12 How do I report bugs (or feature requests) in Windows CE development tools?
1.13 Should I get a copy of Platform Builder 2.11/2.12?
1.14 Where can I find a MIPS or SH3 disassembler?
1.15 Can I write DCOM application under Windows CE?
1.16 Is the SH4 binary compatible with the SH3?
1.17 Does Windows CE support COM?

2. Visual C++ Issues
2.1 What do I really need to write C++ apps for Windows CE?
2.2 Do I need to purchase the Windows CE Toolkit for C++ or Basic to develop for CE?
2.3 Can I use Visual Studio SP3 with the Toolkit for Windows CE?
2.4 Can I use Windows 95/98 to build Windows CE applications?
2.5 My MFC app doesn't run on the device the first time I try?
2.6 I keep getting internal compiler errors? How do I make them go away?
2.7 I use a serial connection to debug and use programs like Remote Spy, but the serial connection speed is slow. How can I make it faster?
2.8 How can I copy files to the emulator?
2.9 Can I use C++ exceptions in my Windows CE application?
2.10 Can I use STL in my Windows CE application?
2.11 I populate my combobox using the resource editor, yet when I run my application under CE all I see is garbage. What can I do?
2.12 Is there a way to edit my Visual C++ files on my handheld?
2.13 How does compiler optimization affect Windows CE executables?
2.14 Where is the Windows CE C runtime library? Is source for the runtime available?
2.15 How can I develop applications for Windows CE 1.0?
2.16 I want to port my Windows desktop application to Windows CE.  What issues will I face?
2.17 I can compile for the MIPS and SHx processors, but I don't see an option for the StrongArm.  What can I do?

3. Third Party Tools and Hardware
3.1 Which databases are available on the Windows CE platform?
3.2 Are there any Text-To-Speech engines for the CE platform?
3.3 I want to write an MP3 decoder for Windows CE. Where do I start?
3.4 Are there any printer libraries for Windows CE?
3.5 How can I work with Pocket Outlook data?
3.6 Is there an FTP client API available for Windows CE?
3.7 How can I copy-protect my Windows CE application?
3.8 Where can I find an XML parser for Windows CE?
3.9 Is GCC available for the Windows CE platform?

4. Windows CE Overview
4.1 How many processes can Windows CE support?
4.2 How many threads can Windows CE run?
4.3 What does the basic Windows CE memory map look like?
4.4 What is Execute-In-Place (XIP) and what does it mean for me?
4.5 I want to make my own shell. Where should I start?
4.6 Can I trash my object store by turning off the power during a file operation?
4.7 How much stack space can I use per thread?
4.8 Why does my Windows CE 2.0 stack blow out, even if I allocated it at compile time?
4.9 What kind of limitations will I encounter using the CE Database?

5. General Windows CE Development
5.1 I can't find an API that I need. What should I do?
5.2 How can I insure only one instance of my application?
5.3 How can I make I application startup on system startup?
5.4 How can I prevent other applications from running while my application is active (how can I keep users from accessing the Start Menu)?
5.5 How can I change task bar settings such as Auto Hide?
5.6 How do I keep my device from auto-suspending?
5.7 How do I detect power-on?
5.8 How can I programmatically turn off the device?
5.9 How can I get battery status?
5.10 How can I determine the device type?
5.11 How can I determine the device name?
5.12 How can I initiate a connection to the desktop?
5.13 How can I tell if ActiveSync is currently running?
5.14 How can I programmatically change the display brightness?
5.15 How do I reboot/reset the device?
5.16 How can I change the size of the object store?
5.17 How can I reprogram the buttons on the device? Can I use hardware buttons to initiate application functionality?
5.18 I am writing a dialog based application. Why doesn't an entry appear in the taskbar or in the task list?
5.19 I want to modify the contact database. What is the contact database name or CEOID?
5.20 What is Venus?
5.21 What is Cedar?
5.22 When is MSMQ going to be available?
5.23 How do I get the time under CE - or, what happened to time()?
5.24 How can I convert a pwi to an rtf?
5.25 How can I determine whether the device has been rebooted/reset since the last time the application ran?
5.26 How can I make a resource only DLL under Windows CE?
5.27 How can I determine the current SIP state?
5.28 How can I change the current SIP state?
5.29 How can I enable or disable the Jot SIP?
5.30 I need an ownerdrawn listbox but they are unsupported. What should I do?
5.31 How can I implement a list view with a checkbox next to each item?
5.32 What is POOM and should I use it?
5.33 How can I programmatically launch a dial-up connection (without using the RAS API)?
5.34 How can I write or read a physical memory location?
5.35 How can I enumerate Windows CE databases from the desktop?
5.36 I need to use IrDA to communicate with other devices. Where should I start?
5.37 How can I show the wait cursor, especially from VBCE?
5.38 How can I print from a Windows CE application?
5.39 How do I register a control under Windows CE?
5.40 I am having problems getting CE RAPI to work properly. What can I check?
5.41 I want to create a mail message then send it. Can I do this using the Mail API?
5.42 How can I display GIF, JPG, BMP, or XBM images in my application?
5.43 Why can't I display 16-bit images from my application using imgdecmp.dll?
5.44 What steps can I take to make my software ready for foreign markets?
5.45 How can I open, change and delete mail messages?
5.46 How can I use ATLCE to sink events?
5.47 Do the Pocket Office applications support automation? Can I use them from VCCE, VBCE?
5.48 I am using VBCE and need to call API functions that require structures, but UDT's are not available.  What can I do? What should I watch out for?
5.49 How can I turn on the device when the serial port has activity?
5.50 How can I start applications on device connect/disconnect?
5.51 Do you have any tips on getting more out of HTMLView?
5.52 How do I get the name of a ADOCE table if I only have an Table ID number?
5.53 How can I determine the amount of free space on storage cards, on the device and in memory?
5.54 How can I disable the OK button on my Windows CE dialogs?
5.55 Which common dialogs are supported under Windows CE?

6. Palm Size Development Issues
6.1 If I don't implement an exit menu item, is there anything I can do to make closing the application easier?
6.2 Why should I pay any attention to WM_HIBERNATE?

7. Common Executable Format (CEF)
7.1 What is CEF?
7.2 Can I use CEF in my current applications?
7.3 Can I have a CEF based dll or ocx?
7.4 Why should I use CEF?
7.5 Is CEF as fast as an application compiled for the platform?
7.6 If I am only targeting one specific device should I use CEF?

8. Installation
8.1 What install packages are available?
8.2 How do I programmatically open a cab file on a CE device?
8.3 How do I start an installation from the desktop?
8.4 How can I keep a cab file from being erased after it is installed?
8.5 What command line switches are available for CeAppMgr?
8.6 My install set is having trouble registering controls on Palm-Size PC devices. What am I doing wrong?
8.7 How can I programmatically open a .CAB file?

9. Help
9.1 What format is Windows CE Help in?
9.2 How should I create help files?
9.3 How can I programmatically launch help?

10. Internal/Undocumented/Hack Corner
10.1 Ways to explore windows CE.
10.2 Hack while you can - it will be harder soon.

10.3 BinaryCompress/BinaryDecompress - built in compression for windows ce

10.4 SetProcPermissions - give your process access to other processes!
10.5 RegFileCopy - make an instant copy of the registry
10.6 GetFSHeapInfo - pointer to object store in physical memory
10.7 Predict.dll offers access to word prediction on Palm Size PC's
10.8 Inspect ROM on the Casio E-100 and find interesting things.
10.9 SetWindowsHookEx really does work, sort of.

10.10 Calstore.dll can be used to access the task database API set.
10.11 How can I reformat a compact flash card?

11. Known CE bugs
11.1 Createprocess on pspc devices doesn't work
11.2 MFC CE 6.0 - Gettime with city set to foreign city. Returns 7/22/1863.
11.3 The voice control will not write recordings to any filename except the default.
11.4 The 6.0 StrongArm compiler creates buggy code.

12. Windows CE Gossip Corner
Note: These are all unverified and included just because they are interesting.
12.1 PPTP will be available in 3.0 but not 2.12.
12.2 A new grid control will be released soon.

12.3 The 2.12 version of Imgdecmp.dll supports 24-bit bitmaps.
12.4 When will VCCE 6.5 be released?

1. General

1.1 Why should I write software for Windows CE?

PDA's are booming! Marketing research organizations like IDC project 40% annual growth in handheld device through 2001. Handheld's are also taking off in the enterprise, and are predicted to be the next big enterprise computing platform.

IDC predicts that consumer 'info appliances' will surpass PC sales in 2001, reaching almost 20 million units.

Windows CE is poised to capitalize on this rapid growth. Microsoft is positioning Windows CE to be an easy choice for enterprise development and use, and is working with many OEM's to promote general consumer use and acceptance of Windows CE.

If you have any experience developing for the Windows platform, you can develop for Windows CE. Other platforms cause you to learn new tools and API's, and do not have the broad support of Microsoft and it's partners. Leverage your knowledge and Microsoft's marketing muscle and start coding for CE!

1.2 What does the CE in Windows CE stand for?

While Microsoft claims the CE does not represent any particular meaning, it has been said that it stands for Consumer Electronics (for the devices CE targets) or Compact Edition. When you are really frustrated with a particular problem or shortcoming you can refer to it as Windows CE (Crippled Edition).  I also like Caveat Emptor.

1.3 I want to learn about Windows CE development. Where should I start?

There are many excellent development resources for Windows CE. First, check out the Windows CE related newsgroups:

Microsoft.public.win32.programmer.wince
Microsoft.public.vb.vbce
Microsoft.public.windowsce
Microsoft.public.vc.vcce
Microsoft.public.ado.wince
Microsoft.public.windowsce.developer.betas
Microsoft.public.windowsce.embedded

Also, check www.deja.com for a nice archive of Windows CE posts going back years. This is probably my number one Windows CE resource.

I also really like the windowsce-dev mail list.  It probably has the purest technical Windows CE content of any source, and is monitored by some of the best CE developers I've seen.  It contains a mix of embedded and application development questions.  I also tend to see issues pop up on this list before they show up on the regular newsgroups.  For example, I read about the Platform Builder price increase 3 weeks before it started being discussed on the newsgroups.  To join, send an email to WindowsCE-Dev@Lists.WindowsCE.com

Check out some of the books mentioned in this FAQ, and visit some of the other Windows CE developer websites.

Finally, there is nothing like experience. If you can afford it, purchase the Microsoft development tools, NSBasic or one of the other development tools available for the platform. Try building a few applications. If you have previous Windows development experience you will find Windows CE development to be only mildly painful ;-)

1.4 What books are available for Windows CE developers?

Here is a list of some of the Windows CE development books available, in no particular order:

  • Inside Windows CE - John Murray
  • Programming Embedded Systems for Microsoft Windows Ce - Jeff McLeman
  • Professional Visual Basic Windows CE Programming - Larry Roof
  • Programming Windows CE - Douglas Boling
  • Windows CE 2 Programming for Dummies - Nick Gratten
  • Essential Windows CE Application Programming - Robert Burdick
  • Windows CE Developers Handbook - Terence Goggin
  • Windows CE from the Ground Up - Jean Louis Gareau (annabooks web site).
  • Sams Teach Yourself Windows CE Programming in 24 Hours - Bsquare
  • Windows Ce : Application Development - Keven Millsap, Marshall Brain

1.5 What are some other developer related Windows CE websites?

Here are some CE developer websites:

Samples, SDK's and other tools.

Information and advice on Visual C++ for CE.

Information and advice on Visual Basic for CE. Home of the vbceUtils control for Visual Basic for Windows CE.

Cool API samples and demoware applications for Windows CE.

Samples from DevCon 99.

Some MFC based Windows CE samples.

ActiveX controls for Windows CE developers.

Used to be RoadCoders.com - general Windows CE articles and other development info.

1.6 Where can I find information on DevCon 99?

Take a look at this excellent site. Microsoft has posted video for all of the sessions at DevCon 99 in Denver. Go to http://events.microsoft.com/isapi/events/pages.asp?s=63814&p=620 for more information.

1.7 I need to learn CE in a hurry - can I take a class?

Let's say you need to learn Windows CE ASAP! Depending on your budget and time constraints you could attend a class or conference. The following companies offer beginning and advanced Windows CE training:

David Solomon Expert Seminars www.solsem.com
Annabooks www.annabooks.com
The Paul Yao Company www.paulyao.com

Also, Microsoft has an annual Windows CE developer's conference, usually somewhere between April and June.

Finally, if you really want to learn now (or have no budget), go to http://events.microsoft.com/isapi/events/pages.asp?s=63814&p=620 and check out the video samples. Doug Boling gave did a one-day "Windows CE for application developer's" seminar at DevCon and it is available here.

If you know of others, or want to add your seminar, class or conference, send an email to faq@cegadgets.com and we'll get you added to the list.

1.8 Things to consider before you design that new Windows CE application.

Click here to read the entire article.

1. Read the logo requirements before you design your application.
2. Make life easy for your users - design for your device.
3. Remember power issues - polling, serial port waste power
4. Handle WM_HIBERNATE
5. Think about internet connectivity.
6. Check GNU for portable source code - your app may already be written.
7. Remember, you can't use VB on Palm Sized PC's running Windows CE 2.0 - 2.11 only.
8. Write a help file for your application
9. Plan to write an installer - it's easy
10. Test on actual devices. The emulator is nice but it is not a true Windows CE device.
11. Don't use floating point operations on if you can help it.
12. Buy a Socket Communications ethernet card - it is worth the money.

1.9 I want to develop using Visual C++. What do I need?

Developing using Visual C++ is nice because it will work on any CE platform.

  • The Visual C++ Toolkit for Windows CE 5.0

This is an older version of the Windows CE development environment. It is missing some nice features offered by 6.0, and does not have support for the PSPC 1.2 SDK, ethernet debugging, etc. Interestingly, it does offer an object store browser that was removed in version 6.0. The 5.0 toolkit also lets you target Windows CE 1.0. The 6.0 product does not.

To develop using Visual C++ 5.0 you will need the following:

Visual C++ 5.0, Professional or Enterprise edition
Visual C++ Toolkit for Windows CE 5.0
HPC or PSPC SDK, downloadable for free from the Microsoft web site.

  • The Visual C++ Toolkit for Windows CE 6.0

The current C/C++ development environment for Windows CE.

To develop using Visual C++ 6.0 you will need the following:

Visual C++ 6.0, Professional or Enterprise edition
Visual C++ Toolkit for Windows CE 6.0
Any of the CE SDK's, downloadable for free from the Microsoft web site.

1.10 I want to develop using Visual Basic. What do I need?

First, you need to have an HPC, HPC Pro or a Palm Size PC running 2.11! Many people have purchased the Visual Basic toolkit, written an application and attempted to copy it to a Nino or some other 2.01 device. It does not work! Below is a list of valid Palm Size devices:

Casio E-15, E-100, E-105
HP Jornada 420 and 428
Compaq Aero A2xxx
Philips Nino 520
Everex FreeStyle 540
Any new Palm Size device released after 9/11/99.

Take a look at the official Microsoft statement http://msdn.microsoft.com/cetools/platform/ppcfeatures.asp under the heading of "Visual Basic Runtime in ROM".

Below are descriptions of the available Visual Basic toolkits.

  • The Visual Basic Toolkit for Windows CE 5.0

The first version of basic that supported Windows CE. It was a challenging and generally unpleasant experience developing software for Windows CE using this tool. While version 6.0 has shortcomings, it is worth the upgrade price to make the switch to the Visual Basic toolkit for Windows CE 6.0. To develop using the Visual Basic, you will need:

Visual Basic 5.0, Professional or Enterprise edition
Visual Basic Toolkit for Windows CE 5.0
The HPC SDK

  • The Visual Basic Toolkit for Windows CE 6.0

The current version of Visual Basic for CE. To develop using the Visual Basic, you will need:

Visual Basic 6.0, Professional or Enterprise edition
Visual Basic Toolkit for Windows CE 6.0
The HPC SDK, HPC Pro SDK or the PSPC SDK v. 1.2.

1.11 What other development tools are available for windows CE?

Check out the full article, with comments and pricing on each tool.

1.12 How do I report bugs (or feature requests) in Windows CE development tools?

Microsoft has a couple of useful email addresses:

Windows CE development tools feature suggestions:
wcetwish@microsoft.com

Windows CE Development Tools Bug Reporting:
wcetbug@microsoft.com

1.13 Should I get a copy of Platform Builder 2.11/2.12?

As an application developer you may think Platform Builder doesn't apply to you. While this is mostly true, Platform Builder includes a wealth of information on the internals of Windows CE, including prototypes for functions not documented in the SDK. The Platform Builder help files also contain great information about the workings of the operating system. While this isn't necessarily going to help you make a better list control, you can find interesting little features like RegCopyFile, which copies the entire registry to a file, or PowerOffSystem.

Unfortunately, Platform Builder is a little pricey, and rumor has it PB will be more so when 2.12 is released. Microsoft will charge up to $3000 for Platform Builder and also require a purchase of 250 Windows CE licenses, putting the total price around $13,000! Not to worry, though.  If you really want to get a copy of Platform Builder 2.12 for evaluation purposes, you can purchase the Universal MSDN subscription (which is roughly $2500 I believe).  MSDN Universal not only comes with PB 2.12, but it also contains all the toolkits, SDKs, development tools, and operating system you will need to develop Windows CE software (or any other software for that matter). 

A 60-day trial edition of Platform Builder 2.12 is included with a subscription to MSDN Universal. You can also obtain a trial edition from a distributor for a small fee, ~ $25. See http://www.microsoft.com/embedded/distributors/distrib.asp for a list of distributors.

1.14 Where can I find a MIPS or SH3 disassembler?

Check out http://www.datarescue.com/idawindowsce.htm for a Windows CE code disassembler.

Delosoft also produces a disassembler for MIPS and SH3 executables. Check out www.delosoft.com for more information.

1.15 Can I write DCOM application under Windows CE?

Windows CE 2.11 and earlier do not contain a DCOM implementation - only inproc servers are allowed at this time. However, is has been mentioned that Microsoft does have DCOM for CE in beta (as of 9/99). Perhaps it will be included with CE 3.0 (Cedar) if everything goes as Microsoft plans.

Intrinsyc has a "DCOM" implementation for CE 2.XX+. While not identical to Microsoft's desktop DCOM implementation, it offers similar functionality. More info can be found at http://www.intrinsyc.com.

1.16 Is the SH4 binary compatible with the SH3?

I found this interesting exchange on the windowsce.com developer mailing list:

When I run any SH3 applications on an SH4 device the program starts to load, but the busy icon freezes and never returns.

Response:

Some folks from Hitachi were here Tuesday promoting their new CE unit, which uses an SH4 chip. I asked whether I would have to recompile my app, and they said YES. In other words, the SH3 and SH4 are not binary compatible.

So in other words, according to the post the SH4 is not backwards compatible with the SH3. I have seen other posts mentioning similar problems; the SH3 application will run on an SH4 but crash in peculiar places, for no apparent reason. These same people say that recompiling their app for SH4 seemed to resolve the problems. Also, the compiler warns if an SH3 app is being downloaded to an SH4 machine.

1.17 Does Windows CE support COM?

Windows CE only supports in-process COM object.  There is talk of extending COM functionality in the next major release of Windows CE.  Here are a few references for getting started with COM and CE:

  • "How to Write and Use ActiveX Controls for Microsoft Windows CE" from the MSDN
  • "The Tools You'll Need to Build Embedded Apps: Windows CE Toolkit for Visual C++ 6.0" from MSJ July 1999. There's a section called "Desktop ActiveX Controls".

I have used ATL quite a bit on the CE platform, and aside from one minor problem with connection points, everything works well.  All of the controls available on the CEGadgets.com main page are written using ATLCE.

See Can I write DCOM applications for Windows CE for information on DCOM and CE.

2. Visual C++ Issues

2.1 What do I really need to write C++ apps for Windows CE?

To develop using Visual C++ 6.0 you will need the following:

  • Visual C++ 6.0
  • Visual C++ Toolkit for Windows CE 6.0
  • Any of the CE SDK's, downloadable for free from the Microsoft web site.

You will also need to be running Windows NT 4.0 with SP3 or greater installed.  You can develo using Windows 95/98 as well, but won't be able to use the emulator (which requires a UNICODE operating system).

2.2 Do I need to purchase the Windows CE Toolkit for C++ or Basic to develop for CE?

Yes, you do need to purchase the C++ or Basic Toolkit. Microsoft gets about $200 for it, but there are third party software vendors that will sell it to you for less. buy.com has it for $167.

The toolkit contains the compilers and linkers needed to create executables for Windows CE.  It contains support for the various processor types supported by Windows CE.

The "SDKs" contain the various header and library files used in actually writing the application.  Each SDK contains any customizations to the Win32 API needed by a particular platform, such as the addition of the SIPINFO APIs for Palm-size PCs.

The Windows CE SDKs are free and readily downloadable at: http://msdn.microsoft.com/cetools/downloads/devkits.asp

You can also use tools like NSBasic ($99) to develop directly on the device...

2.3 Can I use Visual Studio SP3 with the Toolkit for Windows CE?

Microsoft states that SP3 is incompatible with WCE toolkit at this time (9/2/99).

2.4 Can I use Windows 95/98 to build Windows CE applications?

You can run VC 5.0 under Windows 95/98 but you will not be able to use the emulator.

You may be able to run VC 6.0 under Windows 95/98 (but you will not be able to use the emulator). It was mentioned on one of the CE newsgroups that as of 6.0, the Windows CE Toolkit will not allow installs to 95/98, but I have only seen this comment once. I haven't tried this (I did use the 5.0 toolkit on 95 and 98 without trouble). However, several other people have written stating that the 6.0 Toolkit does install under 95/98, so I'd bet that there really isn't any problem with this approach.

2.5 My MFC app doesn't run on the device the first time I try?

Some files (like mfcce20d.dll) are not copied properly during the installation of the toolkit. Check the following page for more info:

http://support.microsoft.com/support/kb/articles/q187/6/16.asp

2.6 I keep getting internal compiler errors? How do I make them go away?

The Windows CE compiler is a little finicky when it comes to code. If you get an error like:

myfile.cpp(234): fatal internal error CBE7002:
try changing your code around a little. Move your declarations, remove extra spaces, etc. Basically just change the code style a little bit and try to compile again. This usually fixes the problem.

2.7 I use a serial connection to remotely debug my x86 applications, but the serial connection speed is slow. How can I make it faster?

Contact MS support for a fix to the TCP/IP stack to increase the speed of Apps debugging with DevStudio Add-in. Note that this applies to remote debugging on x86 based platforms (CEPC, etc).

2.8 How can I copy files to the emulator?

After successfully installing your SDK, look for the Windows CE Platform SDK menu item under Start, Programs. Launch 'Emulation Environment for [platform name]'. This will launch a console window. At this point, type empfile -? for options, or type empfile -c [source filename] wce:[taregt location in object store].

For example, empfile -c e:\CEproject\myapp.exe wce:\windows\start menu\myapp.exe will copy myapp.exe into the emulator object store.

2.9 Can I use C++ exceptions in my Windows CE application?

C++ exceptions are not supported on Windows CE. But Win32 exceptions are. You can use the __try and __except keywords (and also the __try and __finally keywords). MFC exceptions are also supported (TRY, CATCH, etc.)

However, the key words for C++ exceptions (try, catch, and throw -- with *no* leading underscores) are not supported.

2.10 Can I use STL in my Windows CE application?

STL relies on exceptions, and since exceptions are not supported under Windows CE, STL cannot be fully implemented. There are a few ports of STL to CE that do not rely on exceptions. Take a look at:

Search www.deja.com for information on STL and CE for more information. If you have information on other STL ports let me know.

2.11 I populate my combobox using the resource editor, yet when I run my application under CE all I see is garbage. What can I do?

Apparently the resource editor treats the text as ANSI, not UNICODE. You have to populate the listbox programatically.

2.12 Is there a way to edit my Visual C++ files on my handheld?

Logical Sky has produced a syntax highlighting C++ editor for use on HPC and HPC/Pro platforms. Here's a recent press release:

Logical Sky is proud to announce the release of CEdit for Windows CE!

CEdit is a color syntax hilighting C++ editor for Windows CE. CEdit is designed for C++ developers who need to work with their source code when they are away from their desks. CEdit is compatible with Microsoft Visual C++. It allows you to open a Visual C++ project file on your handheld, so that you will have quick access to all of your C++ files.

CEdit is designed for MIPS and SH3 based H/PCs. CEdit will not run on a palm-sized CE device.

A free fully functional 30 day demo is available from: http://www.LogicalSky.com.

CEdit is $49.95.

2.13 How does compiler optimization affect Windows CE executables?

I came across the following interesting post in the windowsce-dev digest:

I've been working on a project targeted to the SH3 processor and I noticed that the Release mode EXE for the SH3 was actually larger that the Debug version with symbols!  After a little thought I remembered an article in MSJ a year or so ago or so discussing the various optimizations of the x86 compiler in DevStudio.  IT said that often the default optimization for speed can be slower that the optimizations for size and that it can get worse for RISC processors.  So I compiled for Size instead of speed and there were MAJOR differences in EXE size.

X.EXE CPU Debug Opt Size Opt Speed
SH3 176K 131K 187K
x86 189K 120K 136K

Additionally I couldn't detect any difference in the speed of the code in a relatively GUI intensive app.

Just thought I share that it's actually worth the time spent trying different optimizations, at least on the RISC processors.

2.14 Where is the Windows CE C runtime library? Is source for the runtime available?

Starting with Windows CE 2.01, Microsoft folded the C runtime directly into coredll (in other words, Windows CE 2.0 for the HPC is the only version that did not do this).  One reason for doing this is to help executables stay as small as possible.  With the runtime and API set in ROM, user applications will stay very small.

Microsoft has not released source to the Windows CE C runtime.

2.15 How can I develop applications for Windows CE 1.0?

If for some reason you are stuck doing development for Windows CE 1.0, you will need the Visual C++ 5.0 and the Windows CE Toolkit for Visual C++ 5.0. VC++ 6.0 does not support the WCE 1.0 platform.

2.16 I want to port my Windows desktop application to Windows CE.  What issues will I face?

There are many issues to consider when porting your application to Windows CE.  You will face many obvious issues, like interface changes, power and memory constraints.  However, you will find many not-so-obvious issues to contend with, as well.

Perhaps the largest issue you will face is making your application UNICODE compliant.  Windows CE is a UNICODE operating system, and all strings used in API calls must be UNICODE.

You may  also need to deal with the following issues: missing API's, thread issues, floating point use, sockets, etc.

Check out the full article, Common Windows CE Porting Issues, for more information.

2.17 I can compile for the MIPS and SHx processors, but I don't see an option for the StrongArm.  What can I do?

Download and install the HPC/Pro SDK from http://msdn.microsoft.com/cetools/downloads/hpcprosdk.asp. This SDK  contains what you need to generate executables for the StrongArm using your Windows CE Toolkit.

3. Third Party Tools and Hardware

3.1 Which databases are available on the Windows CE platform?

Check out the full article, Third Party Database Tools for Windows CE, here!

There are a phenomenal amount of database tools available for the Windows CE platform.  Here is the short list of available CE databases:

3.2 Are there any Text-To-Speech engines for the CE platform?

The are a few text to speech (TTS) engines for Windows CE.

Check out Lernout and Hauspie's TTS engine for Windows CE. This is the same speech engine used in the AutoPC. Unfortunately, it is only available for SH3 processors at the current time. See http://www.lhsl.com/ssyn/tts3000wince.asp for more information.

You should also check out the Dectalk TTS engine for Win CE. Apparently, Dectalk was purchased by Fonix Corp.  See http://www.fonix.com/products/dectalk/ for more information.

Another entry to the Windows CE TTS field is from Elan. The Elan TTS toolkit was released 1-Nov-99 and was $495US at that time. It will support the MIPS and SH processors, and will cover the following languages: US English, UK English, French, German, Spanish, Brazilian and Russian.

Note: $495US covers the developer license. The toolkit also requires distribution royalties, which depend on the number of units you ship. Contact Elan for more information - info@elan.fr, or see their web site at www.elantts.com.

3.3 I want to write an MP3 decoder for Windows CE. Where do I start?

There are currently two MP3 players for the Windows CE platform, and both use the Xaudio SDK to actually do MP3 decoding/playback. The Xaudio SDK is easy to use, well documented, and FREE for personal use (you have to license Xaudio for commercial distribution).

Support for Xaudio development is good as well. Check www.xaudio.com for more information and to download the SDK.

If you really want to "roll your own", there is source for mp3 decoders around on the internet. Try www.mpeg.org for more information.

3.4 Are there any printer libraries for Windows CE?

Check out FieldSoftware's PrinterCE ActiveX control. It provides basic print output routines for CE. FieldSoftware offers a barcode package as well.  PrinterCE is license based, with prices ranging from 19.95 for the basic library, up to $1000 for PrinterCE Plus with barcode support, including 500 licenses.

From a FieldSoftware newsgroup post:

PrinterCE makes sophisticated printing from VBCE simple (no worries about device contexts and BitBlits and DIBsections, etc). Plus, PrinterCE goes beyond just plain printing by adding support for printing from Palm-sized PCs!!! as well as printing barcodes, using specialized label printers, and much more.

Get more information at: www.fieldsoftware.com

3.5 How can I work with Pocket Outlook data?

You should definitely check out the POOM SDK. POOM stands for Pocket Outlook Object Model, and represents a standard, easy to use interface into Contacts, Calendar and Tasks on your Windows CE device. Use this in place of modifying the contact, calendar or task databases directly, or even the AddressCard API.

You can download the POOM SDK at msdn.microsoft.com/cetools/platform/poomsdk.asp.

Along with offering basic access to Pocket Outlook, POOM offers some cool features like ReceiveFromInfrared and SentToInfrared, which will squirt the selected object(s) in/out the infrared port. It also allows you to work with cities on the device.

3.6 Is there an FTP client API available for Windows CE?

While an FTP client is documented in the Windows CE help, no FTP client actually ships with OEM devices.  I have heard two explanations for this.  One, given at CE DevCon 99, was that it was up to the OEM to ship or leave out FTP support, and most left it out.  The other is mentioned in the CE documentation.  While FTP functions are documented, there is a statement in the remarks section: "Inetftp.dll is available only for Intel x86 processors."

Here are two third-party sources for Windows CE FTP controls:

Ruksun makes an FTP client, and has packaged some of their code into a simple to use ActiveX control for developers. Contact komal@ruksun.com for information on the control and licensing.

Dev-soft has a massive set of internet controls for Windows CE developers, including support for HTTP, FTP, IMAP, LDAP, NNTP, SMTP, etc. Here's a snippet from their site re: FTP functionality.

FTP - Used to transfer files using the FTP protocol. Very easy to use with a 'plug and play' interface. Supports most corporate firewalls, and has an extensible architecture, enabling access to non-standard FTP server features (mostly found in mainframes).

The toolkit is also royalty-free.

3.7 How can I copy-protect my Windows CE application?

DESkey sells a dongle that plugs into a PCMCIA or compact flash card slot.  Take a look at http://www.des.co.uk/ for more information.  A free developer's kit is available at www.des.co.uk <http://www.des.co.uk>.

Here's some information about DESKey sent to me by the company:

Manufactured to CompactFlash Standard Type I, this device will allow you to protect your Windows CE 2.x applications against unlicensed use / piracy. In addition to this the DESkey API provides the means for your application to encrypt and decrypt data through the DESkey CF Card.

Features:

CompactFlash Design
Random Number Generator
Code or data from your application may be fed through the DESkey for encryption.
Unique 8 Byte Password
Memory - 1,024 bytes of memory as standard. Up to 32K is available on request.
Anti-Emulation Algorithm
The DK3CF+ supports all popular processors including MIPS, SH3 etc.

Also, take a look at R.I.A. TerraSystems (www.mappad.com).  They offer a key-ring device that works by sending a unique ID to the CE device's infrared port.

There are various software-only based protection mechanisms as well, like creating secret entries in the registry, computing a unique ID based on the user and device characteristics, or requiring a valid serial number (supplied by the author) before allowing the application to run.

3.8 Where can I find an XML parser for Windows CE?

On October 13, 1999, mov Software announced a port of EXPAT to Windows CE.  From the post:

EXPAT is a conforming and non-validating XML 1.0 parser, originally written by John Clark. More information about EXPAT can be viewed at http://www.jclark.com/xml/expat.html

EXPAT is distributed via the GPL or MPL 1.1 licenses. To download the source code for EXPAT for Windows CE please visit http://www.movsoftware.com/devres.htm

EXPAT has been verified to work on the following platforms:
CE2.11
    SH3, SH4, ARM, MIPS
CE2.0
    SH3, MIPS

Take a look at http://www.movsoftware.com/expatxml.htm for more information.

3.9 Is GCC available for the Windows CE platform?

Take a look at http://www.innonet.at/~wisi/index.html. There is a GCC MIPS compiler currently under development, although it still is not ready for release.  From the page:

I am trying to finish a port of GCC to WinCE which I found on the page  http://hyperion.clc.cc.il.us/~arty/. The work there was stopped on September 98 and actually I can't find the page any more.  This guy has already done the most work. I tried just to fix some problems.

At the moment the compiler is still in a pre-alpha state. Simple demo programs are working on my VELO500(e.g.: opening a Message Box).

4. Windows CE Overview

4.1 How many processes can Windows CE support?

Windows CE maps the bottom section of memory into 33, 32Mb slices referred to as 'slots'. The lowest slot is used for the currently running process (the process is mapped into slot 0, not copied!), and other low slots are used for system processes as follows (this is how it appears on my casio e-100):

Slot 0: current running process
Slot 1: NK.EXE (kernel)
Slot 2: Filesys.exe (file system - object store, registry, ceDB etc)
Slot 3: Device.exe (device manager)
Slot 4: Shell32.exe (Windows CE shell)

5 slots are used, leaving 28 remaining slots for user processes.

4.2 How many threads can Windows CE run?

While theoretically there are no limits to the number of threads per process, you will eventually run out of memory and virtual address space. Windows CE 2.x has eight priority levels (default is 3). Foreground threads retain the same priority as all other threads at their level.

Threads in Windows CE are referred to as follows:

  • Time Critical (runs until complete)
  • Highest
  • Above Normal
  • Below Normal
  • Lowest
  • Above Idle
  • Idle

One of the new features in Windows CE 3.0 will be support for 256 priority levels.

4.3 What does the basic Windows CE memory map look like?

The Windows CE address space is 4GB. The bottom 2Gb are used for processes and application shared space. The operating system uses the top 2Gb - hardware, object store and ROM are mapped here (Note that some locations may be different on your device). Have any additional info - please send it to me and I'll add it to the list.

FFFF FFFF: top of memory
BF00 0000: Beginning of ROM area
AB00 0000: I/O Registers on a MIPS R4xxx
AA00 0000: Beginning of screen memory
A000 0000: Beginning of DRAM area
8000 0000: Beginning of kernel memory space
[.]
4200 0000: begin shared app memory (memory mapped files)
4000 0000: slot 32 space
[...]
0400 0000: slot 2 - filesys.exe
0200 0000: slot 1 - nk.exe
0000 0000: slot 0 - current process space

4.4 What is Execute-In-Place (XIP) and what does it mean for me?

Execute In Place is the ability for Windows CE to run applications (or operating system code) right in ROM. There is no need to copy the executable from ROM to RAM and run it - that would just waste time and memory.

As an application developer you should keep this in mind - who knows, Casio or HP might buy your application and, burn it into their next device, and sell it to the masses! So, don't write back to your executable or do anything else that would prevent your application from being ROM'd.

4.5 I want to make my own shell. Where should I start?

Try to beg, borrow or steal the Platform Builder v. 2.12. There is source for a simple Windows CE shell on CD 1. This code is an excellent starting point. Your shell will need to handle the battery monitor, resource checking and WM_HIBERNATE message generation.

BSquare has introduced a new development tool, Interface Composer, which allows the developer to create his own shell.  While I believe this product targets the embedded developer looking to implement a cool shell, it can also be used by the developer to create new, custom shells and skins for distribution to OEM device users.

4.6 Can I trash my object store by turning off the power during a file operation?

The Windows CE development team worked very hard to prevent this. The object store is based on a transactional model, complete with a transaction log tracking the most recent object store operations. If any catastrophe occurs, Windows CE can roll back the log to the last good point. In the case of an interruption during database or file delete, Windows CE can actually roll forward, continuing the operation.

See Inside Windows CE, chapter 4, for a good look at the design philosophy behind the object store.

4.7 How much stack space can I use per thread?

In Windows CE 2.0 the limit was 58K per thread. This was changed in 2.1 to be up to 1Mb (that's a big stack!) per thread. 2.1 also allows setting the stack size at compile time, but all threads in your application will have the same stack size.

4.8 Why does my Windows CE 2.0 stack blow out, even if I allocated it at compile time?

Unlike the desktop, Windows CE 2.0 only allocates application stack space as it is needed. This can cause problems if memory is nearly full and you are allocating on the stack. This was changed in CE 2.1.

4.9 What kind of limitations will I encounter using the CE Database?

Windows CE 2.11 and earlier are limited to 4 indexes. Wince 3.0 is increasing the limit to 8.

I assume you could technically have up to 2^32 records, since records are identified by CEOIDs, and since CEOID's are currently DWORDS. I did see a post online showing that the limit was around 16K records, but I have not verified this. 

However, if you are going to be dealing with more than 1500 records do not use the CE database system - it is really slow.

5. General Windows CE Development

5.1 I can't find an API that I need. What should I do?

When writing Windows CE applications, try to keep in mind the Win CE development team philosophy.  They took a look at the entire Win32 API and included only API's they felt they needed - for example, they would leave out an API if the same thing could be accomplished using three other existing API's.  In other words, if you find that an API is missing, first look around and say to yourself "how could I accomplish the same thing using other API's", since for the most part the Win CE team left out an API if they thought it could be implemented in another way.

Another thing to do is dumpbin /all coredll.lib in your sdk lib directory. There are plenty of API functions (over 2400 on the 2.11 pspc) and one may be just what you need. If you have Platform Builder you have access to the prototypes as well. For example, I just found SetWindowsHookEx, which appears to be similar to the desktop SetWindowsHookEx. The documentation says that SetWindowsHookEx is unavailable, but there it is in coredll.lib.

Also, if you want an API for the HPC 2.00 that isn't documented until 2.11, check the 2.00 coredll.lib anyway. It may be in there. Of course, there may be a reason it is undocumented (ie. it does not work!) so, again, use undocumented functions with care and test, test, test.

And finally, if the API is undocumented it may not be there in future versions. Rumor has it that Microsoft is making big changes to 3.0, and even if they are making little changes, you might get left out.

5.2 How can I insure only one instance of my application?

There are a few methods - the registry, FindWindow(), and CreateMutex().

You can store a value in the registry when your application starts, and remove it when your application terminates.  Unfortunately, if your application crashes is abnormally terminates, your registry value will not be removed.  When you go to run the first instance of your application again, it will see the registry entry and stop running. 

The FindWindow() method is the easiest to implement. In your InitInstance search for another instance of your application name, ie.

HWND hWnd=FindWindow(YOUR_WINDOW_CLASS, YOUR_WINDOW_TITLE);
if(NULL!=hWnd) {

SetForegroundWindow(hWnd);
return 0;

}

Here's some sample VB code you can use to find a window.  This sample assumes the window title is SampleForm.

Public Declare Function FindWindow Lib "Coredll" Alias "FindWindowW" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetLastError Lib "Coredll" () As Long

On Error Resume Next
Dim hWndX As Long

hWndX = FindWindow("Form1", "SampleForm")
If (hWndX <> 0) Then MsgBox "found it!"    '

If you are a VBCE user, you may want to consider creating a c++ launcher that checks for a previous instance of your application and changes focus to it if found.  You can then launch the vb application if it is not running.  As a side benefit, you can also create an icon to go with your vb application.   

Another technique is to use CreateMutex(). You first need to attempt to create a mutex and make sure it does not already exist. If the mutex does exist, you would post a registered message to all the top level windows to tell the application to move itself to the foreground, then close the current instance.

HANDLE hMutex=CreateMutex(NULL, TRUE, _T("YOUR_MUTEX_NAME_HERE"));

if(hMutex && ERROR_ALREADY_EXISTS==GetLastError()) {

// The app is already running
CloseHandle(hMutex);
return 0;

}

5.3 How can I make I application startup on system startup?

KEY_LOCAL_MACHINE\Init contains executables to run during device startup. Executables are listed under LaunchXX keys, where XX determines the run order to use. Another key, DependXX, allows specifying dependencies (ie. Launch50 can't run unless Launch40 was successful).

Create a new key under HKEY_LOCAL_MACHINE\Init named Launch60 (or anything greater than Launch50) , and supply the executable name to run. If you want the exe to launch only if the shell successfully started, create Depend60 and set the value to 32h (hex for 50).

An easier way to start an application on system startup is to put a link to your application in the \Windows\StartUp folder.

5.4 How can I prevent other applications from running while my application is active (how can I keep users from accessing the Start Menu)?

One technique is to disable the taskbar. Using FindWindow, get the handle to the taskbar window and disable it. When your program exits, make sure you enable it though! Also, a disabled taskbar makes it difficult to use the SIP. You may have to manually show/hide the SIP to work around this problem.

Here's an example:

HWND hTaskBarWnd = ::FindWindow(_T("HHTaskBar"), NULL);

if (hTaskBarWnd) {

::EnableWindow(hTaskBarWnd, FALSE);
::ShowWindow(hTaskBarWnd, SW_HIDE);

}

Note that this approach may cause the desktop to not redraw properly. If this is a problem, grab the desktop window and manually resize that as well, as follows:

HWND hDesktopWnd = ::FindWindow(_T("DesktopExplorerWindow"), NULL);

If (hDesktopWnd)

::SetWindowPos(hDesktopWnd, NULL, 0, 0, GetSystemMetrics(SM_CYSCREEN), GetSystemMetrics(SM_CYSCREEN) - 26, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);

Note that 26 is the task bar height. I suppose this could change so it may be a good idea to compute the taskbar height prior to resizing the desktop window.

5.5 How can I change task bar settings such as Auto Hide?

AutoHide and other task bar settings are contained in the registry key HKEY_LOCAL_MACHINE\Software\Microsoft\Shell in a value called TBOpts. TBOpts is a DWORD bitfield containing four entries:

#define MENUOPT_SHOWTIME 0x0001
#define MENUOPT_SHOWDATE 0x0002
#define MENUOPT_SHOWBANNER 0x0004
#define MENUOPT_AUTOHIDE 0x0008

Once you change the TBOpts value to show or hide various task bar settings you need to notify the task bar. The following:

SendMessage(hTaskBarWnd, WM_COMMAND, 0x3EA, 0)

Will notify the taskbar that changes were made and cause it to update accordingly.

5.6 How do I keep my device from auto-suspending?

One way to keep your device from auto-suspending is to issue a keyboard event every n minutes, such as:

keybd_event(VK_F24, 0, KEYEVENTF_KEYUP | KEYEVENTF_SILENT, 0);

If you are using VBCE, try the following:

Public Declare Sub keybd_event Lib "coredll.dll" (ByVal bVK As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

In the timer control event, type (7B is VK_F12 - you could use any character you like):

keybd_event &H7B, 0, 0, 0
keybd_event &H7B, 0, &H2, 0

Another suggestion is to open a socket and keep it open as long as you want the system to stay awake.

Finally, you can use SystemParametersInfo to set the timeout to 0, disabling it. For example,

SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, 0, NULL, TRUE);

The problem I see with this approach is that if your application crashes or somehow manages to exit without putting it back to its previous value, the device will no longer timeout when idle. Even soft resetting the device would not fix the problem, so use this approach with care. When using this approach, the power settings in the control panel show the default settings, but the timeout never occurs.

There is also an undocumented API SetPowerOffHandler, but I have had no luck getting it to work. I can make the device start doing weird power related things, but not exactly what you would want to ship!

5.7 How do I detect power-on?

You can detect power on using WaitCommEvent and the EV_POWER mask. Open a serial port and wait for an EV_POWER event. When the event occurs send your application window a message letting it know that the power was turned back on.

SetCommMask(comportHandle, EV_POWER);
WaitCommEvent(comportHandle, &eventValue, NULL);
SendMessage(hwnd, WM_POWERON, 0, 0);

One caveat - opening the serial port turns on the serial hardware, which takes additional battery power. I don't have any hard numbers on the effect this technique has on battery life (yet).  Another caveat - this may interfere with other applications use of the serial port. Test carefully after implementing this power-on detection technique.

Another way to detect power on was discussed in the Windows CE Tech Journal, September 1999 issue. In the article, Jeff Spurgat described how device drivers receive power state change notifications, and how application developers can latch on to this functionality to receive power on notifications.

Basically, device drivers receive a powerup and powerdown message. Typically, a device driver will power up or power down their hardware based on this notification and return as quickly as possible without calling the kernel or any function that can cause a paging operation. In the article, Jeff simply sets a few global variables when the power state changes. He has a worker thread monitor the state of these variables once per second, and do a PostMessage if the poweron flag is true. Jeff provides sample code as well - both a working power detection driver and a sample application that works with the driver. You can download it here.

Finally, another interesting suggestion is to create an application thread with that fires a timer once every n seconds. Every time the timer fires, compare the current system time (GetSystemTime) with the last (saved) system time value. If the difference exceeds the timer interval the device has been suspended during the interval.

5.8 How can I programmatically turn off the device?

Windows CE treats the power button just like a keyboard key. Because of this, you can simply send a VK_OFF keystroke to the system and it will power off, just like you pressed the off button!

void SuspendDevice()
{

keybd_event(VK_OFF, 0, 0, 0); // down
keybd_event(VK_OFF, 0, 2, 0); // up

// code execution resumes on the next line...
MySampleFunction(); // runs when the device wakes back up...

}

By the way, VK_OFF is defined as 0xDF.

You can also use the PowerOffSystem function. This function is undocumented, so it may change or disappear at any time.

The undocumented function void PowerOffSystem(void) is declared in coredll.dll. It places the CE device in suspend state. However, when power is restored the user password dialog is not shown and the desktop and other windows are not redrawn. Code execution continues at the next line after the PowerOffSystem call.

You can invalidate all windows to get around the redraw problem, and you can also detect the 'prompt for password' state, and if required, display your own password dialog, and use CheckPassword to check the entered password against the user's password.

GwesPowerOff is another power API.  The GWES calls GwesPowerOff when suspending the device.  This may be a better approach than calling PowerOffSystem directly.   Check out http://support.microsoft.com/support/kb/articles/Q207/9/88.ASP for more information. [Thanks to Mike Burch for this tip].

Finally, see Suspending Your Device Programatically for an article and code samples discussing power off APIs.

5.9 How can I get battery status?

Use the GetSystemPowerStatusEx API, available under WCE 2.0 and greater.

5.10 How can I determine the device type?

Use SystemParametersInfo. There is an option SPI_GETPLATFORMTYPE which returns a string containing the platform.

BTW, HPC Pro devices return 'Jupiter'.

5.11 How can I determine the device name?

Note: This key may not be valid on all platforms. Check your platform

Check the registry key HKEY_LOCAL_MACHINE\Platform for a value named 'Name'. The value corresponds to the OEM specified device name. For example, on the casio e-100 it is Casio Jx530 CE2.11. One the Nino 312 it is Philips Version 1.

5.12 How can I initiate a connection to the desktop?

Do a CreateProcess or ShellExecuteEx using \windows\repllog.exe. ReplLog will start an activesync session with the desktop.

5.13 How can I tell if ActiveSync is currently running?

One hack is to do a FindWindow looking for repllog. If you find it, activesync is either running or attempting to connect.

5.14 How can I programmatically change the display brightness?

There is no standard API to change brightness (that I know of). Each OEM implements brightness controls in their own way. If you are interested in modifying brightness check with the OEM or if you can, inspect the OEM display driver.

5.15 How do I reboot/reset the device?

OEM's can optionally handle the IOCTL_HAL_REBOOT in OEMIoControl. However, applications cannot call OEMIoControl directly, but they can call KernelIoControl, which in turn calls OEMIoControl.

#include "winioctl.h"

BOOL KernelIoControl(DWORD dwIoControlCode, LPVOID lpInBuf, DWORD nInBufSize, LPVOID lpOutBuf, DWORD nOutBufSize, LPDWORD lpBytesReturned);
#define IOCTL_HAL_GET_DEVICE_INFO CTL_CODE(FILE_DEVICE_HAL, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_REBOOT CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)

KernelIoControl(IOCTL_HAL_REBOOT, &inVal, 4, outBuf, 1024, &bytesReturned);

If implemented by the OEM this function would perform a soft reset of the device. If you want to perform a hard reset, first call SetCleanRebootFlag.

Note that this did not work on the Casio E-100. Also, future versions of CE will implement SetCleanRebootFlag as a restricted function.

5.16 How can I change the size of the object store?

Note: these functions are documented only in Platform Builder, and are likely to be restricted in future versions of Windows CE.

The functions GetSystemMemoryDivision and SetSystemMemoryDivision allow you to change the relationship between memory and the object store.

The prototypes are:

BOOL GetSystemMemoryDivision(LPDWORD storePages, LPDWORD ramPages, LPDWORD pageSize);

DWORD SetSystemMemoryDivision(DWORD storePages);

The function returns SYSMEM_CHANGED if executed successfully.
The function returns SYSMEM_FAILED if storePages is out of range.
If SYSMEM_FAILED is returned, you can get further information by calling GetLastError.
If a reboot is necessary for the change to take effect, the function returns SYSMEM_MUSTREBOOT.
If a previous call returned SYSMEM_MUSTREBOOT, the function returns SYSMEM_REBOOTPENDING. In this situation, the boundary cannot be adjusted further until the reboot occurs.

You cannot shrink system memory or the object store memory beyond 256K each, including space for existing files and records.

5.17 How can I reprogram the buttons on the device? Can I use hardware buttons to initiate application functionality?

Check out the following API's:

RegisterHotkey
UnregisterHotkey
UnregisterFunc1 (undocumented)

Also, check out http://www.conduits.com/ce/dev/wince.htm and take a look at the keytest example - it contains code to actually do this.

5.18 I am writing a dialog based application. Why doesn't an entry appear in the taskbar or in the task list?

The taskbar only contains buttons for visible, top-level windows that have the WS_OVERLAPPED style. By default, dialog boxes have the WS_POPUP style and thus do not get taskbar buttons. The workaround is to change your dialog box style in the resource editor from WS_POPUP to WS_OVERLAPPED.

There was an interesting report from someone using PB 2.12. They did not want a taskbar button, and did not use WS_OVERLAPPED, but the taskbar button still appeared! Perhaps the default dialog/taskbar behavior has been changed in 2.12.

5.19 I want to modify the contact database. What is the contact database name or CEOID?

You should not attempt to modify the contact database directly, but instead use the API set supplied by Windows CE.

Check out OpenAddressBook, CreateAddressBook, CloseAddressBook, as well as AddressCard, GetAddressCardProperties, ModifyAddressCard, etc.

You may also want to check out the Pocket Outlook Object Model SDK, aka POOM SDK. POOM offers a simple interface into the contact, calendar and task database. You can download the POOM SDK at msdn.microsoft.com/cetools/platform/poomsdk.asp.

5.20 What is Venus?

Venus is produced by Chinese television manufacturer TCL. The Venus computer comes with a 56kb modem and a television interface, and runs the Windows CE OS. Venus provides easy internet access through the user's television. TCL plans to start selling Venus in October, and hopes to sell 300,000 units by the end of the first year.

5.21 What is Cedar?

Cedar is the codename for Windows CE 3.0. It should be release sometime around 2Q 2000. Cedar will contain lots of cool stuff, including more DirectX support, MSMQ, CEF.

5.22 When is MSMQ going to be available?

It will be released as part of Windows CE 3.0. MSMQ is ideal for wireless communications - think of it as transaction based messaging. If some of you information gets lost or mangled on the way to the server you can rollback to the beginning of the transaction.

Rumor has it you should expect Windows CE 3.0 out around 2Q 2000, so I guess you can expect MSMQ around the same time.

5.23 How do I get the time under CE - or, what happened to time()?

Use SYSTEMTIME and GetLocalTime instead, ie.

SYSTEMTIME st;
::GetLocalTime(&st);

5.24 How can I convert a pwi to an rtf?

For VCCE there is a document on MSDN named "Converting Rich Ink Data" that provides code for converting between .pwi and .rtf.

5.25 How can I determine whether the device has been rebooted/reset since the last time the application ran?

Check the registry key HKEY_LOCAL_MACHINE\Comm for the value BootCount. This value is incremented every time the device is soft-reset. If the device is hard reset the value is set back to one.

I received a report that this key isn't found on an HP620LX.  Perhaps it was not implemented in the HPC 2.0 OS.

5.26 How can I make a resource only DLL under Windows CE?

You need to define the entry point to the DLL. Just declare DllMain and have it return TRUE.

#if defined(UNDER_CE) && !defined(_WIN32_WCE_EMULATION)
#include <windows.h>
extern "C"
BOOL WINAPI DllMain (
HANDLE /*hInstance*/, // @parm handle of instance
DWORD /*dwReason*/, // @parm reason
LPVOID /*lpReserved*/ // @parm reserved
)
{
return TRUE; // ok
}
#endif

5.27 How can I determine the current SIP state?

GetSIPInfo allows you to determine the current SIP show state. Unfortunately, GetSIPInfo requires a UDT which is not available in VBCE 6.0. If you need to get the SIP show state from VBCE 6.0, get the vbceSoftKey control from www.cegadgets.com.

5.28 How can I change the current SIP state?

You can control the state of the SIP either using SipShowIM or by filling out the SIPINFO structure and using SetSIPInfo.

SipShowIM is handy because it can be used from VBCE 6.0. The prototype for SipShowIM is BOOL SipShowIM( DWORD dwFlags ), where dwFlags is either of the following:

#define SIPF_OFF 0x00000000
#define SIPF_ON  0x00000001

If you need to retrieve the current SIP display state from VBCE 6.0, get the vbceSoftKey control from www.cegadgets.com.  It is a good idea to query the current SIP state prior to showing it - you don't need to show it if its already up, and you do not want to hide it later if the user has chosen to show it.

SetSIPInfo is more robust - you can also determine the current show, hide state of the SIP, get the SIP rectangle size or the visible rectangle size.  Unfortunately, it is only availble from vcce (until the vbceSoftKey control is updated).

Another approach to showing and hiding the SIP involves finding the SIP window and manually showing or hiding it.  Note that this approach does not rely on aygshell.lib, which is nice if you want the same code to run on an hpc and pspc device.

// created by Dennis Berditchevsky
void UL_RaiseSIP(BOOL bRaise)
{
     // Find window class: "SipWndClass"
     CWnd *pWndKeyb ;
     if( pWndKeyb = CWnd::FindWindow(_T("SipWndClass"),NULL) ) {
          if( bRaise ) {
               if( !pWndKeyb->IsWindowVisible() ) {
                    pWndKeyb->ShowWindow(SW_SHOW);
                    bSipUp_Glob = TRUE; // show it. And not manually.
               }
          } else {
               if( bSipUp_Glob ) {
                    pWndKeyb->ShowWindow(SW_HIDE);
                    bSipUp_Glob = FALSE;
               }
          } //endif(bRaise)
     } //endif(pWndKeyb)
}

5.29 How can I enable or disable the Jot SIP?

You can enable/disable jot via the registry.

There is a registry entry under the Jot registry CLSID key called IsSIPInputMethod. Set this to 0 to hide the method, set it to 1 to show it. Apparently the SIP list displayer checks the registry entries every time it displays the list of available SIP because once you change the registry, the change automatically appears in the list.

The keyname is: HKEY_CLASSES_ROOT\CLSID\{6f311f80-4b14-11d1-ab08-006097490b17}\IsSIPInputMethod.

This method works with other SIPs as well. Just find the CLSID for the SIP you are interested in, change the IsSIPInputMethod to 0, and it will be disabled.

5.30 I need an ownerdrawn listbox but they are unsupported. What should I do?

Ownerdrawn listboxes are not supported under Windows CE. However, use can use a listview control to accomplish the same thing. The listview control can be ownerdrawn, can be set to checkbox style, and has a variety of display modes.

If you are using MFC, create a CListCtrl (either on a dialog via the resource editor or manually using create). Make sure you specify the LVS_OWNERDRAWFIXED style, then handle the DrawItem method. Check out CListCtrl for more information.

Also, if you want to add additional listview functionality, see ListView_SetExtendedListViewStyle. You can see styles like LVS_EX_FULLROWSELECT, which cause the entire row to be highlighted when selected, or LVS_EX_CHECKBOXES, which activates checkboxes on each line of the list view.

5.31 How can I implement a list view with a checkbox next to each item?

Create the listview control normally, then specify:

ListView_SetExtendedListViewStyle(hWnd, LVS_EX_CHECKBOXES);

This causes checkboxes to be displayed in the list control. To set and clear the checkboxes, use:

LVITEM lvi;
lvi.stateMask = LVIS_STATEIMAGEMASK;
lvi.state = UINT((int(isChecked) + 1) << 12);
::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)&lvi);

or if you are using MFC, use:

m_listCtrl.SetItemState(index, UINT((int(isChecked) + 1) << 12), LVIS_STATEIMAGEMASK);

5.32 What is POOM and should I use it?

POOM stands for Pocket Outlook Object Model, and represents a standard, easy to use interface into Contacts, Calendar and Tasks on your Windows CE device. Use this in place of modifying the contact, calendar or task databases directly, or even the AddressCard API.

You can download the POOM SDK at msdn.microsoft.com/cetools/platform/poomsdk.asp.

Along with offering basic access to Pocket Outlook, POOM offers some cool features like ReceiveFromInfrared and SentToInfrared, which will squirt the selected object(s) in/out the infrared port. It also allows you to work with cities on the device.

5.33 How can I programmatically launch a dial-up connection (without using the RAS API)?

Launch \windows\rnaapp.exe using CreateProcess or ShellExecuteEx. For example:

SHELLEXECUTEINFO shInfo;
memset(&shInfo, 0, sizeof(SHELLEXECUTEINFO));
shInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shInfo.lpFile = _T("rnaapp.exe");
shInfo.lpParameters = _T("-e\"work\" -m");
shInfo.lpDirectory = _T("\\windows");
ShellExecuteEx(&shInfo);

This will start the dial-up connection named work. If you need more control over the connection, use the RAS API.

5.34 How can I write or read a physical memory location?

Use VirtualAlloc and VirtualCopy to read or write to physical memory. VirtualAlloc is documented in the CE SDK help, and VirtualCopy is documented in the Platform Builder docs. The prototype for VirtualCopy is BOOL VirtualCopy ( LPVOID lpvDest, LPVOID lpvSrc, DWORD cbSize, DWORD fdwProtect ). VirtualCopy is defined in coredll.dll.

For example:

// PHYSADDR is the physical address of the peripheral registers
#define PHYSADDR ((PVOID)0x10000000)

#define SIZE (4800*4)
LPVOID lpv;
BOOL bRet;
lpv = VirtualAlloc(0, SIZE, MEM_RESERVE, PAGE_NOACCESS);
bRet = VirtualCopy(lpv, PHYSADDR, SIZE, PAGE_READWRITE | PAGE_NOCACHE);

// At this point lpv is a virtual address which maps the memory at PHYSADDR for SIZE bytes

I have had difficulty using this for access to other process slots - one suggestion was to use SetProcPermissions(0xFFFF) but I did not notice a difference. It may be that SetProcPermissions allow you to access other process slots using regular pointers, as opposed to VirtualAlloc/VirtualCopy.

There are a few quirks with VirtualCopy (ie. shifting bits of address, being on a page boundary). Check the docs for more information.

You could also investigate ReadProcessMemory/WriteProcessMemory.

Note that VirtualCopy, SetProcPermissions, ReadProcessMemory/WriteProcessMemory may  become restricted in future CE versions.

5.35 How can I enumerate Windows CE databases from the desktop?

Enumerating your windows ce device databases from the desktop is fairly straightforward.  Simply initialize the rapi interface, grab a handle to the first database and call CeFindNextDatabase until it returns zero.  Use CeOidGetInfo to retrieve information about the currently selected database. Don't forget to include rapi.h and make sure to link rapi.lib into your project.

Here's an example:

CString message;
CString workString;

m_listboxCtrl.ResetContent();

HANDLE dbHandle = CeFindFirstDatabase(0);    // find all db's
CEOID curDB;
CEOIDINFO ceInfo;
while (curDB = CeFindNextDatabase(dbHandle)) {

  ceInfo.wObjType = OBJTYPE_DATABASE;
  CeOidGetInfo(curDB, &ceInfo);
  workString = ceInfo.infDatabase.szDbaseName;

  message.Format("%s\t%i", workString, ceInfo.infDatabase.wNumRecords);
  m_listboxCtrl.AddString(message);

}

There is also an MFC example, wcedbtst, that covers much of the CEDatabase functionality, including reading/writing database records, so I didn't bother covering that here.  The CE RAPI functions I used above are available as part of the Win32 API.

And for more documentation, take a look at the source files shipped with MFC, even if you aren't using MFC .  There is quite a bit of code showing how to implement Win32 API functions, since that is how MFC is built.

5.36 I need to use IrDA to communicate with other devices. Where should I start?

Check out the IrDA article at: http://www.microsoft.com/mind/0599/wince/wince.htm. It gives a detailed explanation if IrDA and some interesting things you can do with it.

5.37 How can I show the wait cursor, especially from VBCE?

If you are using VBCE and want to show a waitcursor, try this code I found in the microsoft.public.vbce newsgroup, posted by Piet De Booser:

Following code works on a PPC but only on the device not in emulation.

Declare Function LoadCursor Lib "coredll.dll" Alias "LoadCursorW" (ByVal
hInstance As Long, ByVal lpCursorName As Long) As Long
Declare Function SetCursor Lib "coredll.dll" (ByVal hCursor As Long) As Long
Const IDC_WAIT = 32514

Function WaitCursor(bOnOrOff As Boolean) As Long

    If bOnOrOff = True Then
        hCursor = LoadCursor(0, IDC_WAIT)
    Else
        hCursor = LoadCursor(0, 0)
    End If
    WaitCursor = SetCursor(hCursor)
End Function

If you are using VCCE you can using the MFC CWaitCursor class, which works nicely, or just the straight SDK function:

SetCursor(SetCursor(LoadCursor(NULL, IDC_WAIT)); // set wait cursor
SetCursor(NULL); // remove wait cursor

You do not need to call DestroyCursor on the wait cursor. It is a shared cursor, and DestroyCursor is only used on cursors created with CreateCursor.

5.38 How can I print from a Windows CE application?

This code was posted online by Tim Fields of Field Software. Fieldsoftware produces an ActiveX print control. See www.fieldsoftware.com for more information. Note: I have not had a chance to try this code.

PAGESETUPDLG pgs;
memset((void*) &pgs,0,sizeof(PAGESETUPDLG));
pgs.lStructSize = sizeof(PAGESETUPDLG);

// pop up page setup dialog box
int rval=PageSetupDlg(&pgs); //fills pgs structure with current settings
if (rval==0) {
     // handle error..
}

// You can now get margin setting values from pgs structure

LPDEVNAMES lpDev;
lpDev=(LPDEVNAMES) GlobalLock(pgs.hDevNames);
BYTE *tbyte(BYTE *) lpDev;
TCHAR *pDeviceName, *pPort, *pDriverName;
pDriverName=(TCHAR*)(tbyte + lpDev->wDriverOffset);
pDeviceName=(TCHAR*)(tbyte + lpDev->wDeviceOffset);
pPort=(TCHAR*)(tbyte + lpDev->wOutputOffset);

// Get the printer DC!! This may pop up an additional printer dialog box
HDC hdc;
hdc=CreateDC(pDriverName,pDeviceName,pPort,NULL);
GlobalUnlock(pgs.hDevNames);

if (hdc==NULL) {
// handle error
}

// You now have your HDC...

// Lets get some values from the page dialog box
LPDEVMODE lpDevMode;
lpDevMode=(LPDEVMODE) GlobalLock(pgs.hDevMode);
if (lpDevMode==NULL) {
// handle error
}

// Get whatever DEVMODE info needed (orientation, paper size, etc)
CurOrientation=(lpDevMode->dmOrientation==DMORIENT_PORTRAIT);
CurIsColor=(lpDevMode->dmColor==DMCOLOR_COLOR);
CurPaperSize = lpDevMode->dmPaperSize;
CurHighPrintQuality = (lpDevMode->dmPrintQuality==DMRES_HIGH);

GlobalUnlock(pgs.hDevMode);

5.39 How do I register a control under Windows CE?

The easy way to register a control is to use regsvr2.exe, a GUI based registration tool. 

If you want to use regsvrce.exe, do the following:

Copy your control into the \windows directory on your device, run regsvrce passing the path and filename of the control as an argument.

For example, to register vbceSoftKeyboard.dll on a Palm Sized PC, you would do the following:

  • type run23 using the keyboard SIP. This will bring up the Run dialog (note- you may have to type run23 a couple of times before it comes up). Sometimes it helps to make the keyboard show, click on the taskbar, then type 'run23'.
  • Type 'regsvrce \windows\vbceSoftKeyboard.dll' and press OK.  Your control is now registered!

You may have to copy regsvrce.exe from your sdk 'target\mips' (or whichever processor you use) directory. 

5.40 I am having problems getting CE RAPI to work properly. What can I check?

Here's a few basic things you can check:

1. Are you sure RAPI is initialized properly?
2. Try to do a simple command, like cecopyfile, to make sure you've got communications working in your app.
3. Are you converting your strings to unicode?
4. Do you have vcce 5.0? under samples\win32 there is ceinvoke - both a client and server demo, that shows how to do this in block and stream mode.
5. Are you converting your strings to unicode? I mention this twice because it appears to be the leading cause of RAPI problems.  See the RAPI example mentioned below for an example of how to use UNICODE strings.

Finally, check Using CE RAPI to Communicate with Windows CE from the Desktop for more information and a few examples.

5.41 I want to create a mail message then send it. Can I do this using the Mail API?

The Windows CE Mail API allows you to add, modify and delete mail messages and mail folder names.  Using the Mail API you can enumerate all messages in any mail folder, change the recipient, subject, body or attachments, and update the entry in the mail store.

The Mail API does not allow for sending or receiving mail at this time. The documentation says that the Inbox acts as a mediator, which means that you can manipulate messages, but it is up to the Inbox application itself to send and retrieve mail.

While I have not tried this, one thing I can suggest is to look at the mail transport functionality. Check out the svcsampl example in  the HPC Pro SDK. It shows (in code) how a simple mail transport service is implemented.  You can also check the SDK documentation for functions like TransportInit, TransportConnect and TransportSend. It appears that pmail loads smtp.dll (the transport service dll) and calls these functions, using TransportSend to send one message at a time.

5.42 How can I display GIF, JPG, BMP, or XBM images in my application?

The easiest way to display images from your (VC) application is by using imgdecmp.dll. Unsupported Software has an article discussing imgdecmp along with some sample source code.

5.43 Why can't I display 16-bit images from my application using imgdecmp.dll?

Well, it turns out that it can!

Many people have difficulty getting 16-bit jpg images to display properly.  Apparently, the trick is to specify dii.iBitDepth = 24.  Imgdecmp.dll does not like 16 as the value.  The S309 control uses imgdecmp.dll and manages to produce 16 bit color images.

It does appear that SHLoadDIBitmap will display 16bit .bmp images. I believe this is what the shell (hence the SH once the front of the API) uses to load the desktop image.

5.44 What steps can I take to make my software ready for foreign markets?

First, take a look at the internationalization session video from the Windows CE DevCon 99, http://events.microsoft.com/isapi/events/pages.asp?s=63814&p=622. There are a lot of great tips on how to make your applications ready for foreign markets. Some of the suggestions include:

  • Place your strings, images, etc in a resource file and make this resource file a .dll. When you want to build an application for another market you will only need to include the new dll and will not have to recompile your application. 
  • Remember that English is a very compact language. Other language strings average 35% longer, with some string more than 2 to 3 times as long.
  • Not all currency symbols are one character (ie. KR for Swedish Krona)
  • Try to avoid culturally specific images. Images acceptable in your country may be embarassing/insulting in another culture.
  • Consider writing all of your strings in Pig-Latin. Pig-Latin is longer than English, so you will encounter string length issues sooner rather than later (and we all know the sooner you find a problem the easier/cheaper it is to fix).

Also, take a look at the NLS API set. It is easy to use and offers functions like GetDateFormat, GetTimeFormat, GetNumberFormat and GetCurrencyFormat.

Finally, if you are a Visual Basic developer you will notice that many of the NLS API functions use UDTs, which are not supported under VBCE 6.0. Take a look at vbceNLS, available on this site for free. vbceNLS allows the VBCE developer to access several NLS functions.

5.45 How can I open, change and delete mail messages?

Windows CE supplies a mail API that allows the Visual C++ developer to add, change and delete mail messages. If you want to work with the inbox under Windows CE you will need to use this API, since at this time POOM does not work with email.

Below is some sample code - it walks through the inbox mail messages and renames the subject line for any that start with 123, and delete the rest:

CString workString;
HANDLE hMail;
MailMsg curMsg;

if (MailOpen(&hMail, FALSE)) {

memset(&curMsg, 0, sizeof(MailMsg));
curMsg.dwFlags = MAIL_FOLDER_INBOX | MAIL_GET_BODY | MAIL_FULL;

BOOL status = MailFirst(hMail, &curMsg);
while (status) {

workString = MailGetField(&curMsg, _T("Subject"), FALSE);
if (workString.Left(3) == "123") {

workString = workString.Mid(4);
MailSetField(&curMsg, _T("Subject"), workString);
MailUpdate(hMail, &curMsg, TRUE);

   } else

MailDelete(hMail, &curMsg);

// prepare to read next message
MailFree(&curMsg);
curMsg.dwFlags = MAIL_FOLDER_INBOX | MAIL_GET_BODY | MAIL_FULL;
status = MailNext(hMail, &curMsg);

  }
  MailClose(hMail);

Make sure to free each mail message you open, and do a MailClose when you are done with mail. 

5.46 How can I use ATLCE to sink events?

Take a look at Ken Rabold's article Sinking COM Events with ATL CE for information on implementing connection points via ATL CE.

5.47 Do the Pocket Office applications support automation? Can I use them from VCCE, VBCE?

Pocket Office does not support OLE Automation, since Windows CE only supports in-process COM objects at this time.

5.48 I am using VBCE and need to call API functions that require structures, but UDT's are not available.  What can I do? What should I watch out for?

Antonio Paneiro has written an article showing how you can use strings to work around the lack of UDT support in VBCE.  Basically, you can populate the string in such a way to make its memory image match the reuired structure definition.  Take a look at http://www.vbce.com/articles/udt/index.asp

One thing to keep in mind: structure in C are often aligned to specific boundaries, for example:

typedef struct
{
    char c;
    short h;
    int n;
} TheHorror;

The internal representation of c = 0x77, h = 0x8899, n = 0xaabbccdd might be (assuming little endian): 77 00 99 88 dd cc bb aa, if aligned on 2byte boundaries or 99 00 00 00 99 88 00 00 dd cc bb aa, if aligned on 4byte
boundaries. [thanks to Russell Harper for this tip, posted on the windowsce vbce newsgroup].

5.49 How can I turn on the device when the serial port has activity?

You can use CeRunAppAtEvent to cause your device to wake up and run an application based on various events, including:

  • When data synchronization finishes
  • When a PC Card device is changed
  • When an RS232 connection is made
  • When the system time is changed
  • When a full device data restore completes

5.50 How can I start applications on device connect/disconnect?

See registry FAQ entry 3.1 How can I start applications on device connect/disconnect?

5.51 Do you have any tips on getting more out of HTMLView?

I personally have suffered at the hands of this dll.  While the dll works great for simple html rendering, you quickly run into trouble when trying to use it for more complicated purposes.  For example, I once attempted to implement a book reader using the html control.  It worked very well, but basic features like setting cursor position were not implemented.  I considered programmatically placing anchors in the HTML to allow navigation but ended up writing my own simple HTML parser/renderer instead.

Anyway, here is an excellent post from Craig Rairdin:

Download our free demo at www.laridian.com to see what we do with the HTML control. We use it for lots of stuff. The next version handles embedded images (.bmp, .jpg, .gif), sounds, and (soon) forms. That version isn't out yet.

Here are some code snippets from our class wrapper around htmlview.dll. You've messed with this enough to fill in any details I might accidentally leave out. You've discovered enough to catch some of the subtleties (some messages have to go to the child window, etc.) 

Here's the Copy operation:

// But, how to copy from the HTML window?  Experimentation has
// shown that if there is a child window, the WM_COPY should be
// sent to the child window.  If there is not a child window,
// the WM_COPY should be sent to this window.
HWND hwnd = GetWindow(m_hWnd, GW_CHILD);
if (hwnd != NULL)
  {
  SendMessage(hwnd, WM_COMMAND, 0x000156BA, 0);
  }
else
  {
  // On the PPC, there's no child window and this window seems
  // to accept WM_COPY
  SendMessage(m_hWnd, WM_COPY, 0, 0);
  }

Note: Copy does goofy things if you display text then resize the window then do a copy. It drops spaces out of the output.

Next, here's CopyAll (I don't think/remember if the getsel and setsel operations really work)

// If there is a current selection, remember it.
// LOWORD(selection) = start position
// HIWORD(selection) = stop position
DWORD selection = SendMessage(m_hWnd, EM_GETSEL, 0, 0);
// Select and copy all contents.
SelectAll();
BOOL CopiedSomething = Copy();
// Restore the prior selection.
SendMessage(m_hWnd,
  EM_SETSEL,
  (WPARAM)(INT) LOWORD(selection),
  (LPARAM)(INT) HIWORD(selection));
// Here's scroll up a line. Up, down, and moving by pages are similar:
HWND hwnd = GetWindow(m_hWnd, GW_CHILD);
if (hwnd != NULL)
  {
  SendMessage(hwnd, WM_VSCROLL, SB_LINEUP, NULL);
  }
else
  {
  // On the PPC, there's no child window.
  SendMessage(m_hWnd, WM_VSCROLL, SB_LINEUP, NULL);
  }

Some other things we learned is that you can't capture Alt+Tap like the docs say you can. On some platforms you even get a menu of some kind when you do Alt+Tap but you can't do anything with it.

Handling the notification messages is pretty much just like the docs say. Like I said above, we handle hotlinks, pics, sounds and are working on forms.

We've talked to Microsoft at length about this .dll. We've concluded that they are embarrassed about it and don't want to talk about it. They have plans to do this better in 2.12 (they've ported IE4 to that platform). You'll be able to have lots more flexibility if/when any devices ship with that version of the browser. Htmlview.dll will go away and you'll have a much more powerful dll to work with.

5.52 How do I get the name of a ADOCE table if I only have an Table ID number?

This helpful post comes from Sandra Walters:

CDB files created with Pocket Access have several 'hidden' tables, among them are MSysTables and MSysFields, just like the Win32 version of Access. MSysTables includes a TableID and a TableName field in each record, which is
how Access relates the two together.

The readme that comes with ADOCE discusses this in detail with lists of fields in each.  I've had to write code to look up table names as well as field names and this document was very helpful.

5.53 How can I determine the amount of free space on storage cards, on the device and in memory?

Use GetDiskFreeSpaceEx to get information about storage card free space. For memory, check out GlobalMemoryStatus.

5.54 How can I disable the OK button on my Windows CE dialogs?

Try the following code in your dialog box:

ModifyStyleEx(WS_EX_CAPTIONOKBTN,0);
RedrawWindow();

5.55 Which common dialogs are supported under Windows CE?

Paul Yao (www.paulyao.com) is an author and Windows CE development instructor.  Below, Paul gives a list of supported and unsupported common dialogs.

There are eight common dialog boxes in Win32.  The File Find is not supported on CE (and therefore the MFC wrapper, CFileFind, would also not be supported).

Here are the eight. Y= supported on CE (at least on HPC); N= Not supported. Note that support for PsPC doesn't include File|Open, File|SaveAs - at least for version 1 of PsPC.

Dialog
HPC/HPC Pro
PSPC

File Open
Y
Y*

File Save
Y
Y*

Print
Y
Y

Print Setup
N
N

Find
N
N

Replace
N
N

Color Picker
Y
Y

Font Picker
N
N

* The PSPC platform displays a modified version of the file open and save as dialogs.  This version does not let you browse the entire file system, but restricts you to the storage card MyDocuments directory and the object store MyDocuments directory.

6. Palm Size Development Issues

6.1 If I don't implement an exit menu item, is there anything I can do to make closing the application easier?

While the Windows CE Pocket applications do not have an exit item, they do close based on the Ctrl-Q keyboard accelerator. Users can close applications by issuing Ctrl-Q from the input panel. It's not a standard or anything (at least I haven't heard about it) but it's easy to do and some people will try it.

6.2 Why should I pay any attention to WM_HIBERNATE?

Ahhh, the neglected WM_HIBERNATE message. The Windows CE shell sends this message when it sees resources running low, and applications are supposed to free resources, memory, and everything else possible short of closing. The shell actually can close applications if things get bad enough.

The WM_HIBERNATE message is actually part of a larger mechanism. The Windows CE shell watches resources based on a timer (the sample shell checks every 5 seconds). Every so often it will check the available resource level, and if the available memory drop below 224K it will send hibernates to all applications. If memory drops below 160K it will attempt to close background applications via WM_CLOSE. In the sample shell shipped with Platform Builder 2.12, the shell nicely sends a WM_CLOSE then waits 8 seconds. If the application still is not close it kills its process (not so nice)! Windows CE actually relies on the shell to close unused applications by sending WM_CLOSE.

Your application should be a good Palm Size Citizen. Free up lists, close files, etc when you receive WM_HIBERNATE. If you receive a WM_CLOSE message, don't show dialogs or other messages - close silently. And definitely do close, because as mentioned above, if you are not closed in 8 seconds the shell will kill you.

7. Common Executable Format (CEF)

7.1 What is CEF?

CEF stands for Common Executable Format. CEF is Microsoft's solution to the problem of multiple processor types.

CEF provides a single target format for Windows CE executable files. The first time a CEF file is executed on a CE device, CE converts the CEF file to native code. This conversion only occurs once and happens very quickly. The resulting code is native to the processor.

Microsoft's goal is to have the executable's performance be at least 80% of native, fully optimized code, and to be only about 20% larger than a native executable.

7.2 Can I use CEF in my current applications?

Get the Visual C++ Toolkit for Windows CE v. 6.01. One of the features added to this version is generation of CEF output.

7.3 Can I have a CEF based dll or ocx?

Yes. CEF will convert dll's and ocx's as well as exe's.

7.4 Why should I use CEF?

CEF's benefit is it's ability to run on any CE device, even ones that didn't exist at compile time.

Microsoft is (currently) committed to handling CEF on each new platform that comes into existence, so if you have an application built for CEF, that application will run on all current processors as well as new processors that come into existence after the product is shipped.

CEF greatly simplifies installation issues. Instead of producing a cab file for each platform type, produce one install set. Executables are converted on the platform once, prior to running.

7.5 Is CEF as fast as an application compiled for the platform?

No. Applications targeting the CEF format are not as heavily optimized as compilations targeting true native code. Microsoft engineers tried to make performance be at least 80% that of a native application.

7.6 If I am only targeting one specific device should I use CEF?

If you are certain that your application will only be run on one type of device (say a Casio PA2400) you should compile to produce native code for that platform. Compiling for native code produces a better optimized and smaller executable.

8. Installation

8.1 What install packages are available?

Windows CE installation packages usually automate the building of cab files, and provide a desktop CEAppMgr launcher. They hide the issues surrounding building ini files, processor codes, etc from you and let you focus on generating an install set.

Here is info on two installation toolkits:

InstallShield CE is a commercial installation package from the same company that dominates the desktop installation world. Their product is straightforward and easy to use, and they offer excellent support. They have a dedicated newsgroup installshield.ce.general which offers prompt support.

They also have a no questions asked return policy, or at least they did for me.

I returned the product because the CE toolkit is only half of what you will need to build a CE installer. You will also need the desktop version of Installshield. The CE version is $495, and the desktop version is between 600-700 dollars. So to build a CE installer using InstallShield be prepared to spend over $1100.

You can find out more about InstallShield CE here.

  • CuteInstall - download here!

Produced by AcerSoftTech in Shanghai, China, CuteInstall is a simple, easy to use install wizard for Windows CE. CuteInstall allows building install sets for all platforms and processor types.

CuteInstall is not as nice as InstallShield, and does not have the support. You are on your own if you need to produce setup dll's, etc.  Also, take a look at the following list, compiled by Nathan Lewis over at InstallShield. This is a list of CuteInstall's shortcomings:

1.  No localization capabilities.
2.  Does not support the "file flags" used for WinCE installations.
3.  Desktop-to-device installer does not provide any kind of scripting capabilities.
4.  Desktop-to-device installer does not provide access Win32 APIs.
5.  Has limited support for H/PC and P/PC devices.
6.  Does not support HPC Professional devices.
7.  Very little error checking done before compiling the INF file.

On the other hand, you should consider CuteInstall in the following situations:

1. shareware/freeware developer - low budget projects
2. someone that needs a simple installer
3. someone that wants to learn about inf/ini files

You will be able to produce an install more quickly using InstallShield than CuteInstall. However, I personally believe that developers should at least try CuteInstall before plunking down the cash for ISCE.  It's freeware, so the only thing they lose is a little time if it turns out not to be helpful.

You can download CuteInstall here.

This installation toolkit will not automatically build your cab files, but it does take care of building an installation tool, and it comes with source code. 

From the web page:

If you are a WinCE author and are looking for an inexpensive way to create / obtain a setup program, look at EZSetup! Once you have created your .cab files (as described in the WinCE SDK), you are ready to use EZSetup. EZSetup takes your .cab files and *outputs* a compressed, self-contained, self-extracting Windows setup program that will set up your WinCE software.

EZ-Setup is freeware and is released under the GNU Public License.

8.2 How do I programmatically open a cab file on a CE device?

Call \windows\wceload.exe using the .cab filename as the parameter, ie.

Wceload myapp.cab

8.3 How do I start an installation from the desktop?

If you are planning on writing your own installation package, you will need to launch the windows ce services application manager, CEAppMgr.exe. To do this, open the registry key

[SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\CEAPPMGR.EXE]

to get the application manager location, then launch the exe providing the installer .ini file as a parameter.

8.4 How can I keep a cab file from being erased after it is installed?

Cab files allow installations to be run directly from the device. The .cab file extension is associated with wceload, which unpacks and installs files contained in the .cab file. Unfortunately, wceload deletes the .cab file after the installation is complete.

You can set your .cab files to read-only to prevent this behavior. While this does not work on HPC 2.0 devices it does work on Palm Size and HPC Pro devices.

Installshield provides a workaround for the HPC problem for their registered users.

8.5 What command line switches are available for CeAppMgr?

With the help of a hex editor I took a look inside of CeAppMgr.exe.  I found the following possible command line switches:

/report - generates dialog boxes reporting the current install step status
/askdest
/noaskdest
/SilentInstall

Unfortunately, except for /report none of them appear to work. Perhaps the next version of CeAppMgr will implement this functionality. 

8.6 My install set is having trouble registering controls on Palm-Size PC devices. What am I doing wrong?

Many people have reported problems with their installation programs. Usually the installer would crash during registration of controls. Apparently wceload.exe on palm-size devices was not calling CoInitializeEx before starting the registration process. Microsoft has issued a fix for the problem, available at: http://support.microsoft.com/support/kb/articles/Q240/4/35.asp

8.7 How can I programmatically open a .CAB file?

Nathan Lewis of InstallShield posted this note regarding .cab files:

You're developing an embedded system, and since Microsoft doesn't provide WCELOAD for embedded systems you're wanting to roll your own, right?  If that is the case, you can start by looking at the "Wotsit's Format" web site (http://www.wotsit.org/  ) in the Windows section.  They have the source to a program that will extract the various files from the CAB.  But that's the easy part...

When CabWiz builds the CAB files, it does two things:  It compiles the INF into an undocumented format, and it renames all of the files in the CAB using the 8.3 format.  Any filenames that are shorter than 8 characters are padded with leading zeros, and any that are longer than 8 characters are converted to short filename format.  The extension for each file is also changed to use exactly three characters, from "000" to "999".  The compiled INF file is stored in the CAB with the "000" extension, and it contains the original filenames for all the other files.  The last file in the CAB always has the "999" extension, which seems to mean that you can never have more than 1,000 files in the CAB (including the compiled INF).

So the basic steps would be:

    1.  Extract the CAB to a temporary directory.
    2.  Parse the compiled INF (*.000)
    3.  Rename the files to their original names and install them.

The compiled INF is the only problem since it's not documented.  I guess you'll have to reverse engineer the file format.  You could start by creating a bunch of simple CAB files using CabWiz, then examine the "*.000" files to try and figure out how they're stored.

9. Help

9.1 What format is Windows CE Help in?

Windows CE help files are simple html files. There are two file extension types for windows CE help; .htc and .htp. The first, .htc, is the main link into your applications help system. Typically, this help file should be named myapp.htc, where myapp is the name of your application. You can use only one help file, or have links into other files. Other files can be named whatever you like, but is it probably a good idea to use a name related to your application, like myapp_config.htp, myapp_usage.htp.

9.2 How should I create help files?

The simplest way I have found is to enter text in Word for Windows, creating links using bookmarks and hyperlinks, then save it as an html file.

9.3 How can I programmatically launch help?

Call \windows\peghelp %1, where %1 is the name of the help file to open.

10. Internal/Undocumented/Hack Corner

10.1 Ways to explore Windows CE.

The Visual C++ Toolkit for Windows CE includes remote spy, remote registry editor and remote process viewer. Use these tools to find system window names, explore and tweak the registry, etc.

Here's a list of ways you can learn more about Windows CE:

  1. Use dumpbin on SDK library files to find out about exported functions
  2. Use dumpbin on emulator dll's to find out about hidden functions
  3. Use loadlibrary to load executable images from ROM into RAM, then write them out to a file and inspect them.
  4. Get Platform Builder - lots of cool stuff here!
  5. Use virtualalloc, virtualcopy to copy process spaces to disk then inspect.
  6. Download CCMemory and inspect memory directly on the device.
  7. Don't bother with GetROMFileBytes - it only works on files that are not XIP (as far as I can tell).

One other thing I found in the docs

"Most miscellaneous files are compressed (with the exception of a few fonts). Code and read-only sections for the executables and DLLs are uncompressed to enable execute-in-place. The read-write sections are compressed because they are destined for RAM, where they will be [de]compressed."

This means that you can dump the ROM to disk and files will be readable (non-compressed).  If you can figure out the ROM file structure you can have access to the entire system. Not only could you disassemble device drivers, but you could copy pocket office to the pspc and try it out.  I'll keep you posted on my progress.

10.2 Hack while you can - it will be harder soon.

Microsoft plans to tighten up security in its operating system by Windows CE 3.0. Certain functions, including VirtualCopy, SetProcPermissions, and other will be restricted to trusted applications only. Here's a brief list of functions that will be restricted:

AddEventAccess, CeSetThreadPriority, CeSetThreadQuantum, CreateAPISet, ForcePageout, GetKPhys, GiveKPhys, GwesPowerOffSystem, LocalAllocInProcess, LocalFreeInProcess, LocalSizeInProcess, LockPages, PowerOffSystem, RegisterAPISet., RemoteLocaleAlloc, RemoteLocalFree, RemoteLocalRealloc, RemoteLocalSize, SetExceptionHandler, SetGwesPowerOffHandler, SetInterruptEvent, SetKMode, SetPowerOffHandler, SetProcPermissions, SetRAMMode, SetSystemMemoryDivision, SetWDevicePowerOffHandler, SystemStarted, ThisIsGwes, UnlockPages, VirtualCopy, VirtualSetPageFlags.

10.3 BinaryCompress/BinaryDecompress - built in compression for windows ce

You can use BinaryCompress and BinaryDecompress to perform buffer compression. BinaryCompress will take a buffer and return a compressed buffer. BinaryDecompress will take a compressed buffer and turn it back into the original. BinaryCompress and BinaryDecompress are defined in coredll.

I assume the compression API uses the same compression as the object store. That compression is comparative - Windows CE compresses the buffer using several methods and takes the winner.

Remember that all files kept in the object store are compressed, so this is redundant if you are just storing data in a file on your device.

Here's an example:

DWORD BinaryCompress(LPBYTE bufin, DWORD lenin, LPBYTE bufout, DWORD lenout);
DWORD BinaryDecompress(LPBYTE bufin, DWORD lenin, LPBYTE bufout, DWORD lenout, DWORD skip);

TCHAR string[] = _T("The quick brown fox jumps over the lazy man who did not come to the aid of his country in time.");
BYTE buffer[1024];
BYTE inpBuffer[1024];

int length = BinaryCompress((BYTE*)string, wcslen(string) * sizeof(TCHAR), buffer, 1024);
BinaryDecompress(buffer, length, inpBuffer, 1024, 0);

AfxMessageBox((TCHAR*) inpBuffer);
CString message;
message.Format(_T("%i, %i"), wcslen(string), length);
AfxMessageBox(message);

In this example, the uncompressed buffer is 188 bytes and the compressed buffer is 148 bytes. Not the best, but it is free.

10.4 SetProcPermissions - give your process access to other processes!

This command will allow you to access memory in other process slots. It currently is available to all processes, but in future versions of CE it will be a restricted function.

The prototype is void SetProcPermissions(WORD procFlag). Each bit in the procFlag refers to a process. To get access to process slot 0, 1, 2 and 3 then procFlag would be 0x000F. To allow access to all processes set the flag to 0xFFFF.

10.5 RegFileCopy - make an instant copy of the registry

This is a great little command. RegFileCopy(filename) will write the registry out to the specified filename. It takes about 1 second on my Casio e-100. There is also a command RegRestoreFile that will restore a .reg file to the registry. I have not used this one yet (as of 9/6) so I cannot comment on its use, but you may want to check it out.

Unfortunately, the output file is not exactly text based. It does look pretty easy to parse, so you could write an application to convert it to text.

10.6 GetFSHeapInfo - pointer to object store in physical memory

Want to have some real fun, and possible really screw up your device? Try this little piece of code:

DWORD objStoreLoc = GetFSHeapInfo();
SetProcPermissions(0xFFFF);
#define SIZE (1024*1024*4)
BYTE* lpv;
BOOL bRet;
lpv = (BYTE*) VirtualAlloc(0, SIZE, MEM_RESERVE, PAGE_NOACCESS);
bRet = VirtualCopy(lpv, (void*)objStoreLoc, SIZE, PAGE_READWRITE | PAGE_NOCACHE);
if (bRet) {

CFile output(_T("\\outputImage.bin"), CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
output.Write(lpv, SIZE);

}
VirtualFree(lpv, 0, MEM_RELEASE);

This writes 4Mb of raw object store out to a file, which you can copy to your pc and proceed to inspect with a hex editor. Remember, all Windows CE buffers will be little endian. The file system is FAT based, too, so search for directory entries and proceed from there.

10.7 Predict.dll offers access to word prediction on Palm Size PC's

Palm Size PC devices use soft keyboards. The standard keyboard also uses a moderate dictionary to try and guess you next word. You can also use the prediction routines and access the dictionary.

Check out Predict dll and the following exported functions:

PredictGetTables
TrieIndexToWord
TrieInit
TriePrefixToRange

I do not have the prototypes yet.

You may also want to check out statdict.dat and dictprob.dat, two files apparently associated with the SIP dictionary gadget. I will post more info as I find it.

10.8 Inspect ROM on the Casio E-100 and find interesting things.

Curious about the internal workings of Windows CE? Want to see weird messages left by the developers, like Woo-hoo! Keyboard type is:  and discover hidden DLL exports like the ones used in jotcore1.dll - ZorroClose, ZorroOpen, ZorroTrain.

It is pretty simple once you know where to look. Lucky for us, EXE's in ROM are not compressed, since they are run in place (Note that they are not in PE format either, but in .bin format.  Check the PB docs for info on .bin format). I made a little program that grabs 4Mb chunks of memory and writes them out to files. I then copy the files to the desktop and read them with a hex editor, like HEdit or Hackman. The ROM image in combination with Platform Builder is a great insight into the working of CE.

Here's some sample code:

#define PHYSADDR ((PVOID)((0xbf000000)))
#define SIZE (1024*1024*4)

BYTE* lpv;
BOOL bRet;

lpv = (BYTE*) VirtualAlloc(0, SIZE, MEM_RESERVE, PAGE_NOACCESS);
bRet = VirtualCopy(lpv, (void*)PHYSADDR, SIZE, PAGE_READWRITE | PAGE_NOCACHE);
if (bRet) {

CFile output(_T("\\outputImage.bin"), CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
output.Write(lpv, SIZE)

}
VirtualFree(lpv, 0, MEM_RELEASE);

This code will write 4 Mb of ROM to a file in the root directory on your device. Simply copy this file to your desktop machine and use your favorite hex editor to review the contents of ROM.

10.9 SetWindowsHookEx really does work, sort of.

If you believe the Microsoft documentation, SetWindowsHookEx does not work under Windows CE. However, if you have read this FAQ you know that SetWindowsHookEx can be found in coredll (2.11 PSPC and HPC Pro versions only). The question is, what does it do, and is it a full implementation.

I have been wanting to write an ATL control that passes messages (like WM_HIBERNATE) to VBCE. One way to do this is to create an ATL control, implement a connection point, and install a windows hook that monitors the message queue, and whenever a relevant message appears, fires an event off to VB. Unfortunately, every combination of

gHook = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC) MyWndProc, gInstance, 0);

returned an error 87 (incorrect parameter). Further searching through the PB header files reveals only three hook-related defines: 

#define WH_JOURNALRECORD 0
#define WH_JOURNALPLAYBACK 1
#define WH_KEYBOARD_LL 20

So I stopped using WH_CALLWNDPROC and tried WH_KEYBOARD_LL, and found that it worked quite well. I actually implemented a hook callback that watched for VK_OFF, and when detected, waited 2 seconds before returning. Whenever I pressed the power button the device would indeed wait before turning off. I also attempted to abort the power off by returning a non-zero number from the hook callback. While this does prevent the power button from powering off the device, it also causes the device to crash. Besides, VK_OFF is only generated when the off button is pressed, and not when a device time-out occurs, so the code was of marginal use. However, if you need to trap other low-level keyboard commands (ctrl-esc, etc) SetWindowsHookEx might be for you.

While I imagine journal record and playback are implemented as well, I have not tried them.

10.10 Calstore.dll can be used to access the task database API set.

Calstore.dll manages access to various task database functionality. I could not find any documentation on the API offered by calstore on the device, but did find the list of exported functions in my Casio E-100 ROM.

ReplAppointmentFromOid
ReplDeleteAppointment
ReplDeleteTask
ReplGetCalendarObjectStore

ReplReleaseAppointment
ReplReleaseCalendarStore
ReplReleaseTask
ReplTaskFromOid

APPTGetMonthData
AdjustForBias
AdvanceRecurNoClone
AppointmentFromOid

CompleteTask
ConvertRenTzToSchedPlus
ConvertSchedPlusToRenTz
CreateAppointment

CreateTask
DeleteAppointment
DeleteTask
EditException

EnumAppointments
EnumExceptions
EnumRecurAppointments
EnumRecurAppointmentsEx

EnumRecurPattern
EnumTasks
ExceptionFromOriginal
FExceptions

FindAppointmentFromGlobj
FreeARI
GetAppointmentData
GetCalendarObjectStore

GetExceptionInfo
GetMinimumPeriod
GetMonthData
GetMonthDataEx

GetPatternStartTime
GetStartAndEndDate
GetTaskData
GetYearData

IsActiveTask
IsApptOid
IsException
IsMeetingUpToDate

IsOccurrenceSameDay
IsOidApptDbase
IsOidTaskDbase
IsOverlappingException

IsRecurring
IsRecurringTask
IsTaskOid
IsToday

MapPMailtoRenRecur
OidFromAppointment
OidFromTask
ReleaseAppointment

ReleaseCalendarStore
ReleaseTask
RenFromStdTimeZoneInfo
ReplSetApptAlarm

ReplSetTaskAlarm
ResetCache
SendAttendeesUpdate
SetAppointmentData

SetAttendeeCriticalChange
SetNextAlarms
SetSnapDate
SetTaskAlarms

SetTaskData
StartTasksEnum
StdTimeZoneInfoFromRen
StopTasksEnum

TaskFromOid
UpdateResponseEntry
WriteLastAlarmDate

The functions don't really do much good without the prototypes, but they are a starting place.

Another way to access calstore functionality is using the Pocket Outlook Object Model, or POOM. See 3.5 How can I work with Pocket Outlook data? for more information.

10.11 How can I reformat a compact flash card?

Formatting a compact flash card from your CE device is fairly straightforward, once you know a couple of key pieces of information.  First, you need to open the compact flash device using:

CreateFile(szVolume, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

Next, you need to actually issues a format command to the device, as follows:

// hVolume is the file opened with createFile
// fv is FMTVOLREQ struct, which contains a DWORD
DeviceIoControl(hVolume, IOCTL_DISK_FORMAT_VOLUME, &fv, sizeof(fv), NULL, 0, &cb, NULL);

See Ben Beasley's source for a full compact flash formatter.

11. Known CE bugs

11.1 Createprocess on PSPC devices doesn't work

For some reason CreateProcess does not appear to work on palm-sized devices. Try ShellExecuteEx instead.

11.2 MFC CE 6.0 - Gettime with city set to foreign city. Returns 7/22/1863.

I came across this post and verified it on my e-100 as well.

The following code fails that worked previously in CE2.00 MFCs: (for Home
Cities outside the US).


CTime t = CTime::GetCurrentTime( );
int y = t.GetYear( ) // returns 1863 instead of 1999
I have traced it to CTime::GetLocalTm( ) returns a structure with tm_year
= -37
Likewise month, day and time information is incorrect in the structure.
It works for a Home City set in the World Clock to US Cities and a few
others in the world but fails when you choose cities in Australia and some
other countries. My guess is that some of the TimeZone information is not
stored for these cities and is causing GetLocalTm to fail. GetLocalTm did
not exist in previous versions of the CE MFCs. GetCurrentTime and GetYear
would previously work directly with the time value and not use GMT and time
zones.
Stephen Whitcher
Mobile Technologies Pty Ltd
Brisbane Queensland Australia (GMT+10:00 - no daylight saving)

11.3 The voice control will not write recordings to any filename except the default.

A recent post on microsoft.public.win32.programmer.wince discussed the fact the the voice recorder would not write the recording out to a user specified name, but always used the default. He was using the Casio E-100. He did the following:

::SendMessage(m_hWndVoice, VRM_RECORD, 0, (LPARAM) (LPTSTR)_T("\\myfile.wav") );

but the resulting filename was always "\\_tmp_file0.wav" (or incremented file1, file2, etc). Another person confirmed the problem and said he had given up using the voice control and gone straight to using the wave API's.

11.4 The 6.0 StrongArm compiler creates buggy code.

"Roman" posted this on the microsoft.public.windowsce newsgroup on 9/30/99:

The ARM compiler included with SDK version 12.00.8274.0 produces buggy code.  The ARM compiler included with 6.01 preview 12.10.8414 works well, and all bugs that found in (12.00.8274.0) appeared to be FIXED...

We compiled the SHA HASH algorithm - it failed with the old ARM compiler, but SH3, SH4, MIPS worked fine.  The CAST algorithm simple crashed the application. We tried with preview 6.01 compiler and found that it worked perfectly!

12. Windows CE Gossip Corner
12.1 PPTP will be available in 3.0 but not 2.12.

From Sebastion in the public.windowsce newsgroup, on 9/30/99: "PPTP support should come with Windows CE 3.0, but not with version 2.12. That's what I have heard yesterday from Microsoft."

12.2 A new grid control will be released soon

01/14/00 - I have heard that the grid control is nearly complete, and that a update for HPC/Pro users is available.  Microsoft is working on an HPC update as well, but it  is not quite ready yet.  If you are having problems with the grid control and are desperate, try sending a note to wcetwish@microsoft.com explaining your situation and asking for the update.

02/13/00 - Apparently an updated, more reliable grid control will be released within the next week or two, if things go as planned.  Finally!

12.3 The 2.12 version of Imgdecmp.dll supports 24-bit bitmaps.

I received a couple of comments suggesting that CE 2.12 version of imgdecmp.dll supports 24-bit color. The current imgdecmp.dll on OEM devices supports 8-bit color only.

12.4 When will VCCE 6.5 be released?

From Steve Maillet in the win32.programmer.wince group on 10/9: "[VCCE 6.5 is] not officially announced as of yet. but based on time frames in the past it was 6-8 weeks after PB was released. SO a couple months is what I expect."

SP3 support should be supported in the forthcoming VC++ toolkit for Windows CE V6.5.

Copyright CEGadgets.com 1998-2001. All rights reserved.
Microsoft and Windows are registered trademarks of Microsoft Corporation
No guarantee or warranty of any kind is offered for information, controls and software on this or any other CEGadgets page. Use at your own risk.

Windows CE Developers FAQ

Posted by krsuncom