Question

Sameer Karkhanis on Thu, 22 Sep 2011 18:51:55


I would like to understand more about the IPC mechanisms available between Metro apps and Win32 apps. For e.g. how would state information or data managed by a Win32 service make it's way into a Metro UI and vice-versa? Looking at the Metro API reference (and subset of Win32 APIs) it looks like the following avenues are possible:

1. Shared Memory (via CreateFileMapping\OpenFileMapping)

2. Socket communication on  localhost

3. XMLHTTP on localhost

Can these mechanisms be used for IPC between Win32 and Metro apps? 


Sponsored



Replies

Sheng Jiang 蒋晟 on Thu, 22 Sep 2011 21:36:01


CreateFileMapping: not supported. 

Socket: use Windows.Networking.Sockets instead

XMLHTTP: not listed. Its network layer WinInet is not supported yet. WWSAPI is listed as partially supported if you are interested in SOAP.

The only supported API listed in the IPC section is the RPC NDR Engine.

Source:Windows Runtime and the Windows API in WinRT docs.

Sameer Karkhanis on Thu, 22 Sep 2011 22:31:32


Windows.Networking.Sockets: There is no explicit mention about communication on localhost. There was some talk (somewhere in BUILD) where MS representative said that the localhost communication will be blocked. Would be great to get some conclusive direction on localhost communication.

Sheng Jiang 蒋晟 on Thu, 22 Sep 2011 22:43:50


The docs says 

privateNetworkClientServer A home or work network – the app can send information to or from your computer and other computers on the same network.

I guess to send information to your own computer, you need to demand the privateNetworkClientServer permission.

By the way, there are some sample code at http://code.msdn.microsoft.com/windowsapps/Association-Launching-535d2cec that could be used to launch a url, which should activate the app registered by the protocol (e.g. the http protocol launches the default browser or the skype protocol launches the skype with phone number ready to call). Theoretically this allows one-way communication.

Mr_Jones_ on Sun, 25 Sep 2011 04:21:15


I downloaded the StreamSocket JS sample, then compiled with privateNetworkClientServer option, 'telnet locahost xxxx' failed.--That means sandbox intends to blocks localhost communication.

"Launching protocol can establish one-way communication"--that's true. Thanks,


Sameer Karkhanis on Sun, 25 Sep 2011 17:24:52


'telnet' failed so I assume the sample is a server? Wondering if it works when the WinRT code is a client and socket server resides in Win32 (on same machine). These nuances of communication aren't documented yet and I am worried that even if something works right now, it may stop to work a few weeks later :(

yhaimovich on Thu, 17 Nov 2011 15:55:42


The only supported API listed in the IPC section is the RPC NDR Engine.

Source:Windows Runtime and the Windows API in WinRT docs.



Where in the docs did you find that RPC NDR is supported for Metro apps?

Sheng Jiang 蒋晟 on Thu, 17 Nov 2011 18:12:07


I was under the impression that WinRT is for Metro apps only. Things can often change at this stage of development, though. I can see a popular demand to use XAML in desktop apps written in C++.

Right now RPC NDR is still listed under the inter-process communication section of the Win32 and COM for Metro style apps (networking) article.



The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP


Rob Caplan [MSFT] on Thu, 17 Nov 2011 18:13:52


Yhaimovich, see Win32 and COM for Metro style apps (networking)

Joaquin Jares on Tue, 24 Apr 2012 14:48:16


CreateFileMapping and OpenFileMapping are supported (http://msdn.microsoft.com/en-us/library/windows/apps/br205753.aspx). The problem is where the file lives.

saran.japan on Tue, 29 May 2012 08:20:14


Hi  Joaquin,

I tried using CreateFileMapping and OpenFileMapping,but i am unable to run it successfully.

In my case ,I am able to get the definition of OpenFileMapping(memoryapi.h--loc(programFiles/windowskit/8.0/include/um)) in metro application but OpenFileMapping used in my metro application is getting failed.

I am launching my metro application from desktop application and I want some data to be transferred to my metro application.

Can you/anyone please share some sample code where we can transfer some data using shared memory

Regards

Saran



Rob Caplan [MSFT] on Tue, 29 May 2012 16:17:25


Hi Saran,

There is no supported way for Metro style apps and desktop apps to communicate with each other. The Metro style app must be self-contained or talk to the network. It cannot rely on or talk to other apps on the same machine.

CreateFileMapping is supported for use within the Metro style app, but it cannot be used to share data with other processes outside of its app package.

--Rob

Mike on Wed, 30 May 2012 02:33:48


you can try this out of sandbox sample at http://forum.xda-developers.com/showthread.php?t=1541924

as long as you have a user install a component on the desktop, it should be fine to communicate between Metro app and desktop.  Maybe this is forbidden by the Windows app store certification, I'm unsure.

warning: this is not my sample, use at your own risk.

saran.japan on Thu, 31 May 2012 02:22:05


Hi Rob,

Thanks for your reply!

I understood that communication is not at all possible between Metro Style apps and desktop apps.

So Is there any alternative?Like you said metro style app can talk to the network.

If yes,Please share some code for the same!

Regards

Saran

Rob Caplan [MSFT] on Thu, 31 May 2012 02:27:07


Hi Saran,

There is no supported means of IPC between Metro style apps and desktop apps. You can talk to a network service on another machine, but cannot loop back to the local machine (except for debugging).

--Rob

Sharad Kumar on Fri, 07 Dec 2012 06:55:50


HI Rob,

How desktop apps can come to know that Metro style apps are running on top of them like Start Screen is running on top of

desktop apps?

Best Regards,

sharad