views:

1159

answers:

6

In a C++ project (i.e. no .NET) on Windows Mobile, I am looking for a way to easily communicate between two independently running applications. Application A would run a service, whereas application B would provide the user some functionality - for which B has to call some of A's functions. I would rather not go through implementing anything in COM.

In fact, I would prefer not to do any kind of serialization or similar (i.e. this would exclude using sockets/pipes/files), but rather have B pass all parameters and pointers over to A, just like if A were part of B. Also, apps C, D and E should be able to do the same with only one instance of A running.

I should add that B sometimes is supposed to return an array (or std::vector or std::map) to A where the size is not previously known.

Is this possible on Windows Mobile and possibly other platforms?

A: 

You've covered pretty much all of the bases available; COM, pipes, sockets, memory mapped files. All processes in Windows have completely separate memory spaces, so you can't share anything without using one of those IPC mechanisms.

Gerald
A: 

On Windows Mobile I seem to remember that all processes are mapped into the same address space. So, create message windows in both processes with known names and or class names and use FindWindow in each process to find the other.

Then, SendMessage with a WM_APP defined message id and a pointer to the data to transmit in wParam or lParam.

If I am wrong and Mobile does partition process memory, then just use WM_COPYDATA which - on the desktop uses memory mapping and so is really fast - to send data between the apps.

Chris Becke
+7  A: 

You can't just share data across processes. I don't recommend COM. Pipes do not exist in Windows CE. Your best route is either a memory mapped file (like on the desktop) or a point to point message queue (nothing like on the desktop). Which is better depends on your usage scenario.

Do not try to use cross process memory with VirtualAlloc as suggested, as it's an unsafe hack unsafe and is not supported on CE 6.0 or later so you'll end up breaking under WinMo 7 and later.

I do not recommend using windows messages and WM_COPYDATA. It's slow, kludgy, and highly prone to errors.

People, please don't just answer questions when you've not used the platform just to try to gain reputation points. If you don't know the platform, let someone else help the guy instead of sending him on a wild goose chase.

ctacke
Thanks, after reading up on it some more, I think I will just have to stick using a local socket (this should hopefully work on all mobile platforms)
Steven
A: 

Since you only need the application (B) to communicate with the service (A), why don't you just use CreateFile and DeviceIoControl with a defined set of IOCTLs?

Johann Gerell
A: 

Here is the good source to start with - http://msdn.microsoft.com/en-us/library/aa446520.aspx You decide which option is the best fit for your needs.

+1  A: 

ctacke, Why don't you recommend COM for such operation?

ofarouk