locked
IPC between Metro apps and Win32 apps

    Question

  • 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? 

    Thursday, September 22, 2011 6:51 PM

Answers

  • 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

    Thursday, May 31, 2012 2:27 AM
    Owner

All replies

  • 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.



    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
    Thursday, September 22, 2011 9:36 PM
  • 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.
    Thursday, September 22, 2011 10:31 PM
  • 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.



    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
    Thursday, September 22, 2011 10:43 PM
  • 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,


    • Edited by Mr_Jones_ Sunday, September 25, 2011 4:23 AM
    Sunday, September 25, 2011 4:21 AM
  • '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 :(
    Sunday, September 25, 2011 5:24 PM
  • 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?
    Thursday, November 17, 2011 3:55 PM
  • 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


    Thursday, November 17, 2011 6:12 PM
  • Thursday, November 17, 2011 6:13 PM
    Owner
  • CreateFileMapping and OpenFileMapping are supported (http://msdn.microsoft.com/en-us/library/windows/apps/br205753.aspx). The problem is where the file lives.
    Tuesday, April 24, 2012 2:48 PM
  • 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



    Tuesday, May 29, 2012 8:20 AM
  • 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

    Tuesday, May 29, 2012 4:17 PM
    Owner
  • 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.

    Wednesday, May 30, 2012 2:33 AM
  • 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

    Thursday, May 31, 2012 2:22 AM
  • 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

    Thursday, May 31, 2012 2:27 AM
    Owner
  • 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

    Friday, December 07, 2012 6:55 AM