locked
How to access Win32 API from my out-of-process WinRT component?

    Question

  • I read in several places that the way to bring legacy code to a LOB app is to use a brokered component. I am looking at the WRLOutOfProcessWinRTComponent sample and try to modify it to call ShellExecute or a similar restricted API. However, since the projects IDL file can only be compiled with WinRT compiler settings, all the Win32 APIs are not accessible.

    So how does this work?

    Wednesday, March 25, 2015 12:09 PM

All replies

  • The WRLOutOfProcessWinRTComponent sample does not implement a brokered Windows Runtime Component. It runs out of proc but inside the app container.

    See Brokered Windows Runtime Components for side-loaded Windows Store apps for more information and links to samples and templates to create Brokered Windows Runtime Components.

    Thursday, March 26, 2015 10:56 PM
  • Thank you Rob. Hmm from your samples/templates it seems we can only write Brokered Runtime Components using C#? This would not be an option, since my app is a JS/HTML one and dragging in the .Net runtime I would like to avoid. Technically it should be possible to write a Brokered Component in C++ as I understand in the end its COM under the hood.

    I see in the manifest of the client app:

    <Extension Category="windows.activatableClass.inProcessServer">
          <InProcessServer>
            <Path>clrhost.dll</Path>
            <ActivatableClass ActivatableClassId="Fabrikam.EnterpriseServer" ThreadingModel="both">
              <ActivatableClassAttribute Name="DesktopApplicationPath" Type="string" Value="c:\test" />
            </ActivatableClass>
          </InProcessServer>
        </Extension>

    Does that mean the Brokered Component could also be in an out-of-proc server? That would make debugging a lot easier, since I can simply set a breakpoint in the servers code.

    • Edited by pkursawe Thursday, March 26, 2015 11:16 PM
    Thursday, March 26, 2015 11:04 PM