【问题标题】:Performing a conditional function based on windows OS [duplicate]基于Windows OS执行条件函数[重复]
【发布时间】:2012-09-09 11:32:55
【问题描述】:

我想知道如何根据我使用的操作系统来执行条件函数,例如,

if ( operatingSystem == Windows7 )
{
   foo()
}
else if ( operatingSystem == WindowsXP )
{
   etc()
}

我很确定预定义的宏对我没有帮助,因为您必须在编译之前选择操作系统宏,我希望这个程序灵活,不幸的是,预处理器宏是我在谷歌时得到的唯一答案它。感谢您的时间!

【问题讨论】:

标签: c++


【解决方案1】:

您可以使用GetVersionEx()。阅读GetVersionEx functionOSVERSIONINFOEX structure 了解如何解释数据的详细信息。

【讨论】:

    猜你喜欢
    • 2019-12-29
    • 1970-01-01
    • 1970-01-01
    • 2014-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多