Initializing and Un-initializing RAPI

RAPI can be initialized using either the CeRapiInit or CeRapiInitEx functions. CeRapiInit will block (that is, not return) until a connection is made to the Windows CE device. This could result in your application being frozen for a long period of time, so it is usual to create a thread and call CeRapiInit on that thread. Note that the function will never return if a Windows CE device never connects. A call to CeRapiInit is very simple since the function takes no arguments and returns an HRESULT.

HRESULT hr;
hr = CeRapiInit();
if(FAILED(hr))
  cout ≪  "Could not initialize RAPI:"
       ≪ GetLastError() ≪ endl;

Remember that an HRESULT is not a handle but rather a 32-bit value that contains error information. The ...

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.