0

我在运行时组件项目(通用)中有程序来获取应用程序 ID,

Platform::Guid MyClass::getAppId()
{
#ifdef WINAPI_PARTITION_PHONE_APP
   return Windows::ApplicationModel::Store::CurrentApp::AppId;
#endif
}

之后我创建了一个Windows 8.1应用程序并调用该函数,它应该会出错,因为我希望 windows phone 只返回数据,但是,它通过了编译,我尝试使用其他宏winapifamily.h,但都失败了。

那么,如何区分Windows 8.1 和Windows Phone App 的目标平台呢?

4

1 回答 1

0
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
   // This code is for Win32 desktop apps
#else
   // This code is for WinRT Windows Store apps
#endif

#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
  // This code is for Windows phone 8
#endif

参考:msdn论坛

于 2016-01-12T14:46:17.500 回答