locked
Using old code vs. the store?

    Question

  • I say the talk on using old C++ code in a project and that you can export a WinRT interface to the code and use it in your metro app. They I've heard that doing this will not allow you to put your app in the store. Can you use your old code that accesses Win32 APIs not allowed to be called from Metro apps and then be allowed to list your app in the store?
    Saturday, September 17, 2011 8:11 PM

Answers

  • Sorry let me clarify my answer a bit.  You can do what you are asking, you just need to clear your desktop-style DLL of the banned APIs.  The way to do this is to do what I suggested above and remove any uses of those APIs.

    If you don't happen to use any of the APIs that are banned by the app store, then you will have no build errors and it will just work.

    I worked with a customer who did this successfully at the BUILD conference with a component of theirs that used SQLLite.

    Hope that helps!

    Tuesday, September 20, 2011 5:13 PM

All replies

  • If you compile your code with /DWINAPI_FAMILY=2, you should get compile errors for any API that you use that is not allowed in apps uploaded to the store.

    Alex Thaman
    Senior Test Lead
    C++ team

    Monday, September 19, 2011 8:29 PM
  • That's not what I asked. There were several examples of how to reuse your old code by wrapping it in a DLL with a WinRT interface exposed.  This is useless if the code is then not allowed to be listed in the App Store.  Since the App Store is the ONLY way to provide apps to users, being able to wrap the old code is a waste of time. Am I wrong?
    Monday, September 19, 2011 11:52 PM
  • Well if the app-store indeed did allow apps to do that, then it would defeat the whole point of not allowing those APIs in the first place. It is similar for WP7. People have hacked around the limitations and managed to P/Invoke native API but those apps would never make it into the app store either. Doing that sort of thing is just an intellectual exercise developers do to satisfy their curiosity.
    http://blog.voidnish.com
    Tuesday, September 20, 2011 12:25 AM
  • Sorry let me clarify my answer a bit.  You can do what you are asking, you just need to clear your desktop-style DLL of the banned APIs.  The way to do this is to do what I suggested above and remove any uses of those APIs.

    If you don't happen to use any of the APIs that are banned by the app store, then you will have no build errors and it will just work.

    I worked with a customer who did this successfully at the BUILD conference with a component of theirs that used SQLLite.

    Hope that helps!

    Tuesday, September 20, 2011 5:13 PM
  • Alex, so answer me this: How can you guarantee me that a critical task that takes longer than 5 seconds will finish before the process gets suspended?

    Tuesday, September 20, 2011 5:32 PM
  • Yep that is a bit of a different question.  Just like the fact that the UI is radically changed to be more useful for other input methods (pen/touch) and you will need to re-think your UI to optimize for this, the application model as a whole has changed to support suspended tasks since Metro-style apps run full screen.  What I suggest is to refactor your application to have the assumption that you could be suspended at any time and you will only have a few seconds to save state.  Depending on your app, this may be easy or hard.

    There is a sample that shows how suspend works in code, and there is a way to ask the OS to defer suspension but I believe 5 seconds is what you get.

    http://code.msdn.microsoft.com/windowsapps/App-activating-and-ec15b168

    Wednesday, September 21, 2011 5:48 PM