有没有检测操作系统的宏...?

发布于 2024-10-03 20:17:07 字数 309 浏览 2 评论 0原文

我计划使用 vista 之后可用的媒体基础 API 编写一段代码。我想在 #if 块中添加代码,例如...

#if <SomeMacro>
// all the classes using MediaFoundation go here.
#endif

我找不到宏来检测操作系统版本。这在 Windows 上通常是如何完成的?我发现 _WIN32 和 _WIN64 可以检测 32 位和 64 位,但没有宏来确定 api 可用性。是否有更好的方法根据 vc 中的 API 可用性来隔离代码?

谢谢, 阿比奈。

I am planning to write a piece of code using the media foundation API which is available after vista. I want to add the code inside a #if block something like...

#if <SomeMacro>
// all the classes using MediaFoundation go here.
#endif

I could not find a macro to detect the operating system version. How is this normally done on windows?? I found _WIN32 and _WIN64 to detect 32-bit and 64-bit but no macros to determine api availability. Is there a better way of isolating code based on API availability in vc..?

Thanks,
Abhinay.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情深已缘浅 2024-10-10 20:17:07

并不真地。您能做的最好的事情就是关闭 WIN32_WINNT 宏,但如果有人转身尝试在 XP 上运行您的应用程序,这对您没有帮助。

Not really. The best you can do is to key off the WIN32_WINNT macro, but that doesn't help you if someone turns around and tries to run your application on XP.

桃酥萝莉 2024-10-10 20:17:07

尝试使用 _WIN32_WINNTWINVER 宏。更多信息请参见:http://msdn.microsoft.com /en-us/library/aa383745%28VS.85%29.aspx

尝试类似,

#ifdef _WIN32_WINNT_VISTA
    #if WINVER >= _WIN32_WINNT_VISTA
        //....
    #endif
#endif

Try the _WIN32_WINNT and WINVER macros. More info here: http://msdn.microsoft.com/en-us/library/aa383745%28VS.85%29.aspx

Try something like,

#ifdef _WIN32_WINNT_VISTA
    #if WINVER >= _WIN32_WINNT_VISTA
        //....
    #endif
#endif
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文