CE Invoke

Windows Mobile SupportedWindows Embedded CE Not Supported

8/28/2008

This code sample is named CEInvoke. It demonstrates a general-purpose mechanism to remotely execute software using the Remote API (RAPI) interface.

Feature Area

Relevant APIs

Projects

There are two projects for this sample:

  • Server
    This is the mobile device-side code. The project builds a DLL called CeInvoke.Dll which contains methods that are invoked by the client desktop program.
  • Client
    This is the desktop-side code.

Usage

The server project will build "ceinvoke.dll" while the client project will build "ceinvoke.exe".

To run the code sample

  1. Navigate to a solution file (*.sln), and double-click it.

    By default, the client solution file is copied to the following folder:

    C:\Program Files\Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\Ceinvoke\Client

    By default, the server solution file is copied to the following folder:

    C:\Program Files\Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\Ceinvoke\Server

    Microsoft Visual Studio 2005 launches and loads the solution.

  2. Build the solution (Ctrl+Shift+B).

  3. Deploy the solution (F5).

If you have not installed the SamplePrivDeveloper certificate, you will need to so that your DLL and CAB projects are signed correctly.

To install the certificate from the windows desktop

  1. Click Start > Run.

  2. Type the path-name to SamplePrivDeveloper.pfx certificate, and click OK. By default, this is located in the following folder:

    C:\Program Files\Windows Mobile 6 SDK\Tools\Security\SDK Development Certificates
    
  3. Double-click the SamplePrivDeveloper.pfx certificate icon. The Certificate Import Wizard appears.

  4. Click Next. The certificate path-name is filled-in.

  5. Click Next.

  6. Click Next (you do not need a password).

  7. Click Next. Accept the default options; automatically select the certificate store based on certificate type.

  8. 9. Click Finish.

See Windows Mobile Powered Device Security Model for further details on how to install the SDK certificates onto the mobile device, and how to use the privileged SDK certificate to sign this application.

Using the application

The desktop-side code is a Windows application without a user interface. The project builds an executable called "ceinvoke.exe". The results are displayed in a simple message box. You can run the executable from the command-line with the parameters in the following table.

Command-line Parameter Test Result

No param

Simple Block

Returns an error code

StoreInfo

Simple Block

Returns the store info on the mobile device

S1

Simple Stream

Returns text specifying Stream Mode 1

S2

Multiple Stream

Returns a list of all of the databases on the mobile device

You can also run the executable from within Visual Studio by altering Project > Settings > Debug > General Category > Program Arguments.

Remarks

The code sample runs on the desktop host computer, and is not supported for emulation.

This server application must run as Privileged, which means it must be signed with a security certificate that is in the privileged certificate store on the mobile device. You must install the SamplePrivDeveloper.pfx certificate so that your DLL and CAB projects are signed correctly.

CeInvoke.dll must exist in the Windows folder on the mobile device (i.e., "\windows\ceinvoke.dll"), or at the root of the mobile device folder hierarchy (i.e., "\ceinvoke.dll").

It is the responsibility of the RAPI extension to release the IRAPIStream object (that is, to call pIRAPIStream->Release()).

The Remote Access Security Policy on Windows Mobile is set to Restricted by default. These devices are considered "Locked," which prevents you from using CeRapiInvoke to invoke device-side DLLs — unless you take extra steps to satisfy the Remote Access Security Policy.

Note

Although the device is still locked, CeRapiInvoke is permitted on Windows Mobile 6 Classic device.

CeRapiInvoke gives elevated privileges to any DLL that can be invoked on the device.

For more information on RAPI security, see Security for Windows Mobile Powered Devices.

Development Environments

SDK: Windows Mobile 6 Professional SDK and Windows Mobile 6 Standard SDK

Development Environment: Visual Studio 2005.

ActiveSync: Version 4.5.

See Also

Concepts

Code Samples for Windows Mobile

Other Resources

Windows Mobile Powered Device Security Model
RAPI Restricted Mode Security