共用方式為


RAPI Initialization

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

Before you can invoke any RAPI functions, you must initialize the underlying communications layer between the host computer and the Windows Embedded CE device, which must be connected to the host computer through a cable or a cradle. There are two versions of the RAPI initialization function you can use: CeRapiInit (RAPI) and CeRapiInitEx (RAPI). CeRapiInit does not return until the connection is made, an error occurs, or another thread calls CeRapiUninit (RAPI).

CeRapiInitEx works slightly differently. Instead of blocking the calling thread, it returns an event handle to indicate when initialization is complete. Use CeRapiInitEx to avoid blocking a thread inside a call to CeRapiInit. CeRapiInitEx returns immediately and continues initialization until the connection is made, until an error occurs, or until there is a call to CeRapiUninit. When CeRapiInitEx is complete, it sets the event specified in the heRapiInit member of the RAPIINIT structure. After calling CeRapiInitEx, check the return value to determine whether an error occurred. If the call was initially successful, call the MsgWaitForMultipleObjects function to wait for the event handle passed back in the heRapiInit member of the RAPIINIT structure. When the event is set, check the hrRapiInit member of the RAPIINIT structure to determine whether the connection was successful. To shut down or to stop the connection process, call the CeRapiUnInit function.

Note

When initializing the RAPI library in a multi-threaded application, be mindful of the access restriction between apartments. If RAPI is initialized in an STA thread, RAPI will not be accessible from other apartments.

See Also

Other Resources

RAPI Reference
RAPI Reference