Email:   
Home
In This Issue
Email a Friend
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
PROGRAMMING POWER
Palm-sized input panel quirks and mounted database volumes
By Steve Makofsky

Welcome to Windows CE Magazine's Programming Power column. Each month we address tough issues about writing software for Windows CE and provide solutions that usually include a code snippet or two.

Based on reader questions and feedback, every month we select questions that are common stumbling blocks in Windows CE development. Want to know how to work around an API that's not available on Windows CE? Need help determining if your code will work on both a palm-sized PC and a H/PC Pro? Send us email at poweranswers@bsquare.com, including code where appropriate, and we'll try our hardest to find a resolution for you.

Most of the topics we cover are for those of you using the Visual C++ Toolkit for Windows CE, but we'll address occasional questions about Visual Basic for Windows CE and other development tools as well. Let's jump into this month's questions:

How can you determine if the SIP (Software Input Panel) API (Applications Programming Interface) is available on a device at runtime?
There are two different methods for handling application development across the various Windows CE platforms:

Method #1 -- static linking using definitions
The easiest way to deal with the differences in handheld PCs (H/PCs) and palm-sized PCs (P/PCs) is to have conditional #ifdef statements in your code which will only compile specific API calls if a certain platform is defined. When compiling, the build process will ignore any code inside your #ifdef statement if the condition isn't defined. Since you'll be performing separate builds for each platform, you can also have multiple resource files, which make user interface development easier when dealing with the difference between palm-sized PCs and other Windows CE devices. You can use the #ifdef statement as follows:

#ifdef PALMSIZEDPC
if(SipStatus() == SIP_STATUS_AVAILABLE)
fSipAvail = TRUE;
#endif

You might already notice the big downside to this method -- you'll need to distribute separate executables for both the H/PC and the palm-sized PC.

Method #2 -- dynamic linking
If you'd rather only distribute a single executable, you can determine what functions are available on the running platform by dynamically linking with functions. The function SipStatus() is used to determine the current availability of the SIP on Windows CE 2.1 and higher. This function (and the other SIP calls) are located in \Windows\Coredll.dll. So, in order to determine if you're running on an H\PC Pro or a palm-sized PC, you can code this:

typedef BOOL (*PCORE_SIPSTATUS)();

BOOL IsSIPAvail()
{
PCORE_SIPSTATUS lpfnSipStatus = NULL;
HINSTANCE hCoreInst = NULL;
BOOL fSIPAvail = FALSE;

// Load up coredll.dll and hook into the SipStatus function
if((hCoreInst = LoadLibrary(TEXT("\\windows\\coredll.dll"))) != NULL)
lpfnSipStatus = (PCORE_SIPSTATUS)GetProcAddress(hCoreInst, TEXT("SipStatus"));

// If SIPStatus is there, then call it to see if it's available
if(lpfnSipStatus != NULL) {
if(lpfnSipStatus() == TRUE)
fSIPAvail = TRUE;
}

FreeLibrary(hCoreInst);
return fSIPAvail;
}





[ Next ]

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
-- Advertisement --

EASY DEDICATED AND VIRTUAL DEDICATED SERVERS FOR AS LOW AS $67.99 PER MONTH
Customize and configure your own dedicated server. Simply choose one of our popular plans or select your own Linux or Windows server and plan options.

NO LONG WAITS. Server provisioned within hours.

Tap here now and be up and running with your own server tonight.

-- Advertisement --

CLEARSYNC - THE BETTER SHARING CALENDAR
ClearSync is wherever you are.
Access your account from:
  • Your PC, Mac, or Linux machine
  • Your Palm OS handheld
  • Any online browser

ClearSync works even without Internet access.
ClearSync tracks and saves your changes on your computer, so you're not stranded like with most online calendars.

Tap here to get your life in sync FREE for 30 days!

Copyright © 1999-2009, ZATZ Publishing. All rights reserved worldwide.
Editor's Login