Error Checking

< BACK  NEXT >
[oR]

As with any operating system, it is imperative to check the return results when calling Windows CE API functions never assume that the function works. Many of the code samples in this book do not have sufficient error-checking code for use as production code, so you will need to add it if you take code from this book for use in your own applications.

Nearly all Windows CE API functions return a value indicating success or failure, but little information detailing the nature of the error. You should call the function GetLastError to determine the actual error number encountered. You can look up the error numbers in the header file winerror.h, where you will find a short description of the error. This file is located in the "\Windows CE Tools\wce300\MS Pocket PC\include", or another folder appropriate to the SDK version you are using. The on-line documentation often lists the common errors encountered when calling specific Windows CE functions.

Windows CE devices, unlike Windows NT/98/2000, do not support the FormatMessage function for producing textual descriptions of error numbers, but the function does work under emulation watch out for this one.

Adding comprehensive error-checking code can increase significantly the size of your application's code. With memory-tight Windows CE devices, this can be a problem. You should therefore place debug-specific error-checking code in #ifdef / #endif compiler directives with the _DEBUG define so that the code will not be included in your released application.

 #ifdef _DEBUG   // perform error checking that does not need to be in   // the production version #endif 

< BACK  NEXT >


Windows CE 3. 0 Application Programming
Windows CE 3.0: Application Programming (Prentice Hall Series on Microsoft Technologies)
ISBN: 0130255920
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net