6

Is there a new macro to determine in code if the application is running on WinRT? As I'm working with LoadLibrary, it would be great if there is a macro to replace all calls to LoadLibrary with one to LoadPackagedLibrary...

I'm understanding the documentation correct as in I can load any DLL (as long as it's inside my package) via LoadPackagedLibrary, right?! (And as long as that DLL doesn't use black-listed APIs...)

MFH
  • 1,664
  • 3
  • 18
  • 38
  • You mean like #if NETFX_CORE? – Filip Skakun Aug 14 '12 at 22:36
  • Sorry, I guess that's for .NET. Maybe for C++ you could use [WINAPI_FAMILY](http://stackoverflow.com/questions/9509166/what-is-winapifamily-h) – Filip Skakun Aug 14 '12 at 22:40
  • Well as I'm currently using only the LoadLibrary-related stuff from . So via `#if WINAPI_FAMILY WINAPI_FAMILY_APP` I can determine whether or not I'm on WinRT? – MFH Aug 15 '12 at 00:06
  • Well, I have never done it, so I am not sure, but if it is your application - you should be able to tell yourself if it is a WinRT app or a WinAPI app. Unless you are asking about whether you are running on a Windows on Arm (WoA)/Windows RT tablet - then I have no idea how to check that. – Filip Skakun Aug 15 '12 at 05:16
  • Well I want to have a generic code (it's already compatible with Windows and Linux, simply based on the platform dependent macros...) Now MS replaces `LoadLibrary` for WinRT but all other functions I use are still allowed... – MFH Aug 15 '12 at 09:54

3 Answers3

5

I recently updated to Visual Studio 2012, and think I found the answer to my question:

Inside the Microsoft Headers the Macro WINAPI_FAMILY_PARTITION is used to determine the "Level" of WinAPI. Currently there are WINAPI_PARTITION_DESKTOP and WINAPI_PARTITION_APP, therefore I "guess" that via this macro one can differentiate between Desktop and Metro...

The two macros lead to another set of macros: #define WINAPI_FAMILY_APP WINAPI_PARTITION_APP and #define WINAPI_FAMILY_DESKTOP_APP (WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_APP). Therefore if WINAPI_FAMILY_APP is defined one should be able to assume that it's a Metro application...

MFH
  • 1,664
  • 3
  • 18
  • 38
2

To add your to answer, please see this article Dual-use Coding Techniques for Games

In the introduction part

Apps written for the Windows Store make use of the Windows Runtime (WinRT) and a restricted subset of Win32 APIs located in the core API family (indicated by WINAPI_FAMILY set to WINAPI_PARTITION_APP). Traditional Win32 desktop apps have access to a larger desktop API family (indicated by WINAPI_FAMILY set to WINAPI_PARTITION_DESKTOP), but this is subject to various levels of OS support required for each function

onmyway133
  • 45,645
  • 31
  • 257
  • 263
0

Try __WRL_WINRT_STRICT__ . Not entirely sure that's the right one, but if you go look in that file it will probably have what you want.

From here and here.

N_A
  • 19,799
  • 4
  • 52
  • 98