Handling Errors

Errors can occur either in the way the RAPI function is called on the desktop, or on the execution of the function on the Windows CE device. If a RAPI function call fails, the function CeRapiGetError returns an error from the device, or 0 if the error was a Win32 error. GetLastError can be called to determine the actual desktop error in this case. The following code shows error handling for a failed RAPI function.

int nErr = CeRapiGetError();
if(nErr == 0)
  cout ≪ "RAPI function failed, Win32 Error"
                  ≪ GetLastError() ≪ endl;
else
  cout ≪ " RAPI function failed, RAPI Error"
                   ≪ nErr ≪ endl;

Get Windows® CE 3.0 Application Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.