locked
Support of Windows7 Sensor/Location API in Metro App

    Question

  • Hi Guys,
    We're developing an Metro App (with WinRT component to wrapping underlying code) that require sensors & location functionality.
    The underlying code referenced in WinRT is based on Windows 7 Sensor/Location API, since it's first developed to be used in Win7.

    Our biggest concern is whether the Windows 7 Sensor/Location API are supported by Metro application, according to MSDN http://msdn.microsoft.com/en-us/library/windows/apps/hh464945.aspx it's mentioned that these 2 devices API sets are not allowed by Metro application.

    Then if we want our code work both in Win7 and Win8 Metro, we've got to have 2 set of implementations?(Windows 7 Sensor/Location API -- Win7; Windows::Devices::Sensors/Geolocation -- Win8 Metro?)

    Friday, April 06, 2012 6:35 AM

Answers

  • Correct, the Windows 7 Sensors/Location Win32/COM APIs are available only in the Windows 8 Desktop SDK.  So the code that you developed for Win7 using these APIs will support in Windows 7 and Windows 8 desktop only.

    While this means re-writing code for your Metro style app, the Windows::Devices::Geolocation and Windows::Devices::Sensor APIs provide a simpler model to access sensors and location functionality, so the mapping should be fairly straightforward.


    Friday, April 06, 2012 5:22 PM

All replies

  • Correct, the Windows 7 Sensors/Location Win32/COM APIs are available only in the Windows 8 Desktop SDK.  So the code that you developed for Win7 using these APIs will support in Windows 7 and Windows 8 desktop only.

    While this means re-writing code for your Metro style app, the Windows::Devices::Geolocation and Windows::Devices::Sensor APIs provide a simpler model to access sensors and location functionality, so the mapping should be fairly straightforward.


    Friday, April 06, 2012 5:22 PM
  • Thanks Lisa. By the way, in order to use Windows 7 Sensors/Location Win32/COM APIs we've got to use CoCreateInstance(), which could not pass the package validation. But I found that the alternative CoCreateInstanceFromApp() could not completely replace CoCreateInstance().

    For example:

    hr = CoCreateInstance(CLSID_Location, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&pLocation)); // will succeed
    CoCreateInstanceFromApp will fail...

    Sunday, April 08, 2012 4:43 PM
  • Package validation is only a requirement for Metro style apps.  You should be able to continue using CoCreateInstance(CLSID_location, ...) for your desktop app.

    Monday, April 09, 2012 7:14 AM
  • Hi Lisa, unfortunately I'm trying to do the replacement since our app will target metro mode.
    I started another thread on this issue:http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/cbdc2ae7-a4b5-4429-8e73-58ca846c797a
    Thanks a lot for your help, ;)
    Tuesday, April 10, 2012 6:57 AM