Sunday, January 29, 2006

Using CeRapiInvoke RAPI function

Remote Application Programming Interface or RAPI is a mechanism by which a desktop application can call routines on a windows ce or pocket pc device. There are many RAPI functions but one of the most powerful is CeRapiInvoke function. By using CeRapiInvoke function, your application can virtually do everything possible on the terminal.

For using CeRapiInvoke a dll targetted for the device needs to be created. This dll executes calls on the device on behalf of the desktop application. It can take parameters and can send back return values to desktop app. The signature of CeRapiInvoke function is:
HRESULT CeRapiInvoke( 
LPCWSTR pDllPath,
LPCWSTR pFunctionName,
DWORD cbInput,
BYTE* pInput,
DWORD* pcbOutput,
BYTE** ppOutput,
IRAPIStream** ppIRAPIStream,
DWORD dwReserved
);
The dll is remotely loaded when CeRapiInvoke call is made by the desktop application. Then remote function with name pFunctionName is called. If value of ppIRAPIStream is NULL then the function is blocked and hence desktop application is blocked till the remote function returns.

Waiting for another event in IST (Interrupt Service Thread)

I had a requirement to execute same code as in the IST function of a driver but when a different event is triggered elsewhere in the system. I tried to use WaitForMultipleObjects function for the new event along with the IST event in an array but it failed. Documentation says that only WaitForSingleObject function can be used to wait for the event that is triggered by the kernel. While looking for more information on the topic, I found this article by Mike Hall. It says that Windows CE has this restriction to ensure the upper bound on the time to trigger the event and time to release the IST. IST latency is thus guaranteed.

I solved this problem by creating another thread before IST function gets executed. The new thread has a WaitForSingleObject call to wait for the new event to get signalled. As soon as this new event is signalled, partial copy of the original IST code runs which is what I wanted.

First post

If you are developing applications, drivers or platforms based Windows CE or Pocket PC, then this is a place to watch out. I am going to write about tips, tricks and internals of Windows CE and Pocket PC.

This is a start.

This page is powered by Blogger. Isn't yours?