locked
Using non-RT APIs

    Question

  • My understanding was that Metro apps cannot use anything that uses non-WinRT APIs. But then I found this:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh441569(v=vs.110).aspx

    which indicates that one of the reasons you might want to create a WinRT component in C++ is "to access Windows operating system services that are not accessible through the Windows Runtime in the current version."

    Does this mean that we can create a WinRT component that accesses non-WinRT APIs, write a Metro app that uses the component, and distribute the app and component through the store? If so, are there restrictions on what the component is allowed to do?

    Monday, February 27, 2012 5:47 PM

Answers

  • You can create a component which access non-WinRT API and include that component in with your app.

    The application can call any Win32 API which is in the Application Family, but cannot call API which are in the Desktop Family. See Win32 and COM for Metro style apps for a list of Win32 API which can be called from Metro style apps.

    The Metro style app is still restricted to its sandbox and several of these API will work within the app's package and data. They cannot be used to break out of the isolated sandbox.

    --Rob

    • Marked as answer by cdunford Tuesday, February 28, 2012 2:21 PM
    Monday, February 27, 2012 6:33 PM
    Owner

All replies

  • You can create a component which access non-WinRT API and include that component in with your app.

    The application can call any Win32 API which is in the Application Family, but cannot call API which are in the Desktop Family. See Win32 and COM for Metro style apps for a list of Win32 API which can be called from Metro style apps.

    The Metro style app is still restricted to its sandbox and several of these API will work within the app's package and data. They cannot be used to break out of the isolated sandbox.

    --Rob

    • Marked as answer by cdunford Tuesday, February 28, 2012 2:21 PM
    Monday, February 27, 2012 6:33 PM
    Owner
  • OK, so the component is restricted to the same subset of Windows APIs as the application?

    If that's the case, I don't really understand the statement I quoted: that components are useful "to access Windows operating system services that are not accessible through the Windows Runtime in the current version." What "Windows operating system services" can they access that the app itself can't access?

    Monday, February 27, 2012 7:43 PM
  • They cannot access any services that the app itself cannot access, but they can access services which are allowed but which are not provided via a WinRT class. If your goal is a single Metro style app in C++ then there isn't a lot of value here since the app could call the same Win32 API directly, but it can be valuable if you want to expose those services or other C++ library code to Metro style apps in JavaScript or C#.

    --Rob

    Monday, February 27, 2012 9:06 PM
    Owner
  • I understand.

    Thanks for the response.

    Monday, February 27, 2012 9:10 PM