free web page counters

Windows Mobile Pocket PC Smartphone Programming

==>Click here for the SiteMap<==. Original contents with decent amount of source codes.

Wednesday, May 03, 2006

Pocket PC Console for standard input and standard output: A convenient tool for lazy debugging and tracing in Pocket PC 2003 devices

====>SiteMap of this Blog<===

Pocket PC Console for standard input and standard output: A convenient tool for lazy debugging and tracing in Pocket PC 2003 devices

Debugging and tracing sometimes can be a tricky business, especially for a multi-threaded program.

  • Log file is used most commonly.
  • OutputDebugString is also nice, and there is no need to write any code to deal with a log file. However, you do need to attach the debugger to receive the debugging message.

Probably the simplest approach, requiring neither a log file nor a debugger, is the famous printf (or the C# equivalent Console.Write, or the Java equivalent System.out.println). The simplicity of using printf, and the beautify of showing messages on a console in real time, make printf a very nice tool for lazy programmers :)

Pocket PC Shell

Unfortunately there is no built-in console (therefore no standard input and standard output) in Windows Mobile devices. Even if your code compiles and builds correctly, there is no way you can see the messages.

One tool coming for rescue is PPC Command Shell, part of Microsoft Windows Mobile Developer Power Toys. See my article "How to launch a program via command line in Pocket PC 2003 device and Pocket PC 5.0 device?" for a brief introduction on those nice little tools.

  • PPC Command Shell - Command shell for the Pocket PC 2003 device.

Once installed, three files can be found in the desktop PC's destination folder:

  • console.dll: copying it to the device's \Windows folder
  • shell.exe: copying it to any folder in the device
  • cmd.exe: copying it to any folder in the device

The only files needed for printf to work are console.dll and shell.exe. These two provide the console, supporting standard input and standard output. Once invoked, shell.exe stays in the memory. In fact, upon running, shell.exe put an entry under registry HKLM\Init, so as to make sure itself is always up and running (even before the OS kernel components, like device.exe, gwes.exe, and etc.)


The executable cmd.exe is not needed. It solely provide implementations of some commonly used DOS prompt commands, for example, dir, cd.

Below is a simple testing program:

printf("This is a test");
MessageBox(NULL, TEXT("Console Test!"), TEXT("Demo"),

And here is the screen cut when the program runs:

Warning: This tool does not work in Pocket PC 5.0 device, nor does it work in any Smartphone device. In fact, the following warning is popped up if running in Smartphone 2003 device:

Wrap Up

Pocket PC Shell is a simple yet powerful tool for debugging or tracing in real time. However, the one packaged in Microsoft's Mobile Power Toy can only work in Pocket PC 2003 device (inclduing 2003 SE).

There is another free tool but I've never tested it. Looks like it has not been updated for quite a while.

Notice: Never compile printf into your release build! The printf and console processing code are not simple thus sort of eating the CPU!

====>SiteMap of this Blog<===

[ [permalink] ]


At June 28, 2006 7:31 AM, Anonymous rsolo said...

I intalled the PPC Command Shell exactly as directed. It seemed to install properly, but when I attempt to exectute it (e.g.: click on cmd.exe) nothing happens.

Device is Verizon XV6700 running windows mobile 5.0.

Any suggestions?

Please reply back to

At October 10, 2006 5:09 AM, Anonymous Anonymous said...

I am also facing similar problem
Device is HP iPAQ running windows mobile 5.0 ...

At February 11, 2009 12:14 AM, Blogger uiyui said...

Catch the wow gold star that holds your gold in wow destiny,cheap wow gold the one that forever maplestory money twinkles within your heart. Take advantage of precious opportunities while they still sparkle before you. Always believe that your buy maplestory mesos ultimate goal is attainable cheap mesos as long as you commit yourself to it.maple money Though barriers may sometimes stand in the way of your dreams, remember that your destiny is hiding behind gold kaufen Accept the fact that not everyone is going to approve of the choices Maple Story Accounts you've made. Have faith in your gold farmen Catch the star that maple story money twinkles in your heart and it will lead you to your destiny's path. Follow that pathway and uncover the sweet sunrises that await you. Take pride in your accomplishments, as they are stepping stones to your dreams. Understand that you may make mistakes, powerlevelbut don't let them discourage mesos Value your capabilities and talents for they are what make you truly unique. The greatest gifts in life are not purchased, but acquired through hard work and determination.maplestory mesos Find the star that twinkles in your heart?for you alone maplestory powerleveling are capable of making your brightest dreams come true. Give your hopes everything you've got and you will catch the star that holds your destiny.

At April 13, 2009 7:08 AM, Anonymous Anonymous said...

For using with PPC 5.0 and WM 6 - 6.1
It needed a registry hack:

set HKEY_LOCAL_MACHINE\Drivers\Console\OutputTo to 0.

Do not edit values in registry unless you are an experienced user.
Don't forget to get registry backup before editing it.

At May 06, 2009 12:42 AM, Blogger Srini said...

Thanks for the valuble information it did worked well for me with printf.
Keep it up your good work

At May 21, 2009 10:00 PM, Anonymous amar kishore(SEM expert) said...

Here u can archive more information about search engine optimization and implement your site .also you can improve your site in major search engine. search engine optimization


Post a Comment

Links to this post:

Create a Link

<< Home